cherry-pick with_alt_time helper decorator from 0.11

This commit is contained in:
sebres 2019-06-11 15:49:04 +02:00
parent 809acb69e5
commit 93727abeb8

View file

@ -245,6 +245,17 @@ def with_tmpdir(f):
shutil.rmtree(tmp)
return wrapper
def with_alt_time(f):
"""Helper decorator to execute test in alternate (fixed) test time."""
@wraps(f)
def wrapper(self, *args, **kwargs):
setUpMyTime()
try:
return f(self, *args, **kwargs)
finally:
tearDownMyTime()
return wrapper
# backwards compatibility to python 2.6:
if not hasattr(unittest, 'SkipTest'): # pragma: no cover