Neels Hofmeyr | dae3d3c | 2017-03-28 12:16:58 +0200 | [diff] [blame^] | 1 | # osmo_gsm_tester: prepare a test run and provide test API |
| 2 | # |
| 3 | # Copyright (C) 2016-2017 by sysmocom - s.f.m.c. GmbH |
| 4 | # |
| 5 | # Author: Neels Hofmeyr <neels@hofmeyr.de> |
| 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU Affero General Public License as |
| 9 | # published by the Free Software Foundation, either version 3 of the |
| 10 | # License, or (at your option) any later version. |
| 11 | # |
| 12 | # This program is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU Affero General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU Affero General Public License |
| 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | |
| 20 | import sys, os |
| 21 | import pprint |
| 22 | import inspect |
| 23 | |
| 24 | from . import suite as _suite |
| 25 | from . import log |
| 26 | from . import resource |
| 27 | |
| 28 | # load the configuration for the test |
| 29 | suite = _suite.Suite(sys.path[0]) |
| 30 | test = _suite.Test(suite, os.path.basename(inspect.stack()[-1][1])) |
| 31 | |
| 32 | def test_except_hook(*exc_info): |
| 33 | log.exn_add_info(exc_info, test) |
| 34 | log.exn_add_info(exc_info, suite) |
| 35 | log.log_exn(exc_info=exc_info) |
| 36 | |
| 37 | sys.excepthook = test_except_hook |
| 38 | |
| 39 | orig_stdout, sys.stdout = sys.stdout, test |
| 40 | |
| 41 | resources = {} |
| 42 | |
| 43 | # vim: expandtab tabstop=4 shiftwidth=4 |