From 58717c185484e643b808c3c77feb2520d36e88f3 Mon Sep 17 00:00:00 2001 From: sebres Date: Mon, 17 Oct 2016 13:26:24 +0200 Subject: [PATCH] fail2ban-testcases: persistently set (python) time zone to CET during test cases process (used in zone-related test-cases) --- fail2ban/tests/utils.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/fail2ban/tests/utils.py b/fail2ban/tests/utils.py index fc60f87b..ae543e3d 100644 --- a/fail2ban/tests/utils.py +++ b/fail2ban/tests/utils.py @@ -260,6 +260,10 @@ def initTests(opts): raise unittest.SkipTest('Skip test because of "--no-network"') unittest.F2B.SkipIfNoNetwork = F2B_SkipIfNoNetwork + # persistently set time zone to CET (used in zone-related test-cases), + # yoh: we need to adjust TZ to match the one used by Cyril so all the timestamps match + os.environ['TZ'] = 'Europe/Zurich' + time.tzset() # set alternate now for time related test cases: MyTime.setAlternateNow(TEST_NOW) @@ -292,17 +296,10 @@ old_TZ = os.environ.get('TZ', None) def setUpMyTime(): # Set the time to a fixed, known value # Sun Aug 14 12:00:00 CEST 2005 - # yoh: we need to adjust TZ to match the one used by Cyril so all the timestamps match - os.environ['TZ'] = 'Europe/Zurich' - time.tzset() MyTime.setTime(TEST_NOW) def tearDownMyTime(): - os.environ.pop('TZ') - if old_TZ: # pragma: no cover - os.environ['TZ'] = old_TZ - time.tzset() MyTime.myTime = None