mirror of https://github.com/fail2ban/fail2ban
cherry-pick with_alt_time helper decorator from 0.11
parent
809acb69e5
commit
93727abeb8
|
@ -245,6 +245,17 @@ def with_tmpdir(f):
|
||||||
shutil.rmtree(tmp)
|
shutil.rmtree(tmp)
|
||||||
return wrapper
|
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:
|
# backwards compatibility to python 2.6:
|
||||||
if not hasattr(unittest, 'SkipTest'): # pragma: no cover
|
if not hasattr(unittest, 'SkipTest'): # pragma: no cover
|
||||||
|
|
Loading…
Reference in New Issue