From 07d4badfd069bb79d8d3a4562cc8de943c185c7b Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 10 Jun 2014 13:45:29 +0200 Subject: [PATCH] testExecuteTimeout fixed: give a test still 1 second, because system could be too busy --- fail2ban/tests/actiontestcase.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fail2ban/tests/actiontestcase.py b/fail2ban/tests/actiontestcase.py index f1ea77ce..5a58149f 100644 --- a/fail2ban/tests/actiontestcase.py +++ b/fail2ban/tests/actiontestcase.py @@ -186,8 +186,10 @@ class CommandActionTest(LogCaptureTestCase): # Should take a minute self.assertRaises( RuntimeError, CommandAction.executeCmd, 'sleep 60', timeout=2) - self.assertAlmostEqual(time.time() - stime, 2, places=0) - self.assertTrue(self._is_logged('sleep 60 -- timed out after 2 seconds')) + # give a test still 1 second, because system could be too busy + self.assertTrue(time.time() >= stime + 2 and time.time() <= stime + 3) + self.assertTrue(self._is_logged('sleep 60 -- timed out after 2 seconds') + or self._is_logged('sleep 60 -- timed out after 3 seconds')) self.assertTrue(self._is_logged('sleep 60 -- killed with SIGTERM')) def testCaptureStdOutErr(self):