|
29 | 29 | # NO ASSOCIATION |
30 | 30 |
|
31 | 31 |
|
| 32 | +__module__ = """tests.profiling""" |
| 33 | +"""This is pythonrepo testing module Template.""" |
| 34 | + |
| 35 | + |
32 | 36 | try: |
33 | 37 | import sys |
34 | 38 | if sys.__name__ is None: # pragma: no branch |
|
54 | 58 | raise baton |
55 | 59 |
|
56 | 60 |
|
| 61 | +try: |
| 62 | + if 'functools' not in sys.modules: |
| 63 | + import functools |
| 64 | + else: # pragma: no branch |
| 65 | + functools = sys.modules["""functools"""] |
| 66 | +except Exception as badErr: # pragma: no branch |
| 67 | + baton = ImportError(badErr, str("[CWE-758] Test module failed completely.")) |
| 68 | + baton.module = __module__ |
| 69 | + baton.path = __file__ |
| 70 | + baton.__cause__ = badErr |
| 71 | + raise baton |
| 72 | + |
| 73 | + |
57 | 74 | try: |
58 | 75 | import time |
59 | 76 | if time.__name__ is None: # pragma: no branch |
@@ -150,8 +167,6 @@ def do_time_profile(func, timer_name="time_profile"): |
150 | 167 | >>> |
151 | 168 |
|
152 | 169 | """ |
153 | | - import functools |
154 | | - |
155 | 170 | @functools.wraps(func) |
156 | 171 | def timer_profile_func(*args, **kwargs): |
157 | 172 | """Wraps a function in timewith() function.""" |
@@ -196,7 +211,9 @@ def do_cprofile(func): |
196 | 211 |
|
197 | 212 |
|
198 | 213 | """ |
| 214 | + @functools.wraps(func) |
199 | 215 | def profiled_func(*args, **kwargs): |
| 216 | + """Wraps a function in profile.enable/disable() functions.""" |
200 | 217 | profile = cProfile.Profile() |
201 | 218 | try: |
202 | 219 | profile.enable() |
@@ -242,7 +259,7 @@ def nothing(*args, **kwargs): |
242 | 259 | return inner |
243 | 260 |
|
244 | 261 |
|
245 | | -def main(argv=None): # pragma: no cover |
| 262 | +def main(*argv): # pragma: no cover |
246 | 263 | """The Main Event makes no sense to profiling.""" |
247 | 264 | raise NotImplementedError("CRITICAL - test profiling main() not implemented. yet?") |
248 | 265 |
|
|
0 commit comments