|
33 | 33 | import sys
|
34 | 34 | if sys.__name__ is None: # pragma: no branch
|
35 | 35 | raise ImportError("[CWE-758] OMG! we could not import sys! ABORT. ABORT.")
|
36 |
| -except Exception as err: # pragma: no branch |
37 |
| - raise ImportError(err) |
| 36 | +except Exception as badErr: # pragma: no branch |
| 37 | + baton = ImportError(badErr, str("[CWE-758] Test module failed completely.")) |
| 38 | + baton.module = __module__ |
| 39 | + baton.path = __file__ |
| 40 | + baton.__cause__ = badErr |
| 41 | + raise baton |
38 | 42 |
|
39 | 43 |
|
40 | 44 | try:
|
41 | 45 | if 'os' not in sys.modules:
|
42 | 46 | import os
|
43 | 47 | else: # pragma: no branch
|
44 | 48 | os = sys.modules["""os"""]
|
45 |
| -except Exception: # pragma: no branch |
46 |
| - raise ImportError("[CWE-758] OS Failed to import.") |
| 49 | +except Exception as badErr: # pragma: no branch |
| 50 | + baton = ImportError(badErr, str("[CWE-758] Test module failed completely.")) |
| 51 | + baton.module = __module__ |
| 52 | + baton.path = __file__ |
| 53 | + baton.__cause__ = badErr |
| 54 | + raise baton |
47 | 55 |
|
48 | 56 |
|
49 | 57 | try:
|
50 | 58 | import time
|
51 | 59 | if time.__name__ is None: # pragma: no branch
|
52 | 60 | raise NotImplementedError("[CWE-440] We could not import time. Are we in the speed-force!")
|
53 |
| -except Exception as err: |
54 |
| - raise ImportError(err) |
55 |
| - exit(3) |
| 61 | +except Exception as badErr: # pragma: no branch |
| 62 | + baton = ImportError(badErr, str("[CWE-758] Test module failed completely.")) |
| 63 | + baton.module = __module__ |
| 64 | + baton.path = __file__ |
| 65 | + baton.__cause__ = badErr |
| 66 | + raise baton |
56 | 67 |
|
57 | 68 |
|
58 | 69 | try:
|
59 |
| - import cProfile |
60 |
| - if cProfile.__name__ is None: # pragma: no branch |
61 |
| - raise NotImplementedError("[CWE-440] We could not import cProfile. ABORT!") |
62 |
| -except Exception as err: # pragma: no branch |
63 |
| - raise ImportError(err) |
64 |
| - exit(3) |
| 70 | + if 'cProfile' not in sys.modules: |
| 71 | + import cProfile |
| 72 | + else: # pragma: no branch |
| 73 | + cProfile = sys.modules["""cProfile"""] |
| 74 | +except Exception as badErr: # pragma: no branch |
| 75 | + baton = ImportError(badErr, str("[CWE-758] Test module failed completely.")) |
| 76 | + baton.module = __module__ |
| 77 | + baton.path = __file__ |
| 78 | + baton.__cause__ = badErr |
| 79 | + raise baton |
65 | 80 |
|
66 | 81 |
|
67 | 82 | try:
|
68 | 83 | try:
|
69 | 84 | sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), str('..'))))
|
70 | 85 | sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), str('.'))))
|
71 | 86 | except Exception as ImportErr: # pragma: no branch
|
72 |
| - print(str('')) |
73 |
| - print(str(type(ImportErr))) |
74 |
| - print(str(ImportErr)) |
75 |
| - print(str((ImportErr.args))) |
76 |
| - print(str('')) |
77 |
| - ImportErr = None |
78 |
| - del ImportErr |
| 87 | + |
79 | 88 | raise ImportError(str("[CWE-758] Profile module failed completely."))
|
80 |
| -except Exception: # pragma: no branch |
81 |
| - raise ImportError("[CWE-440] Failed to import test profiling") |
| 89 | +except Exception as badErr: # pragma: no branch |
| 90 | + baton = ImportError(badErr, str("[CWE-758] Test module failed completely.")) |
| 91 | + baton.module = __module__ |
| 92 | + baton.path = __file__ |
| 93 | + baton.__cause__ = badErr |
| 94 | + raise baton |
82 | 95 |
|
83 | 96 |
|
84 | 97 | class timewith():
|
|
0 commit comments