diff --git a/fail2ban/tests/action_d/test_badips.py b/fail2ban/tests/action_d/test_badips.py index 2f3b6723..2d08b5df 100644 --- a/fail2ban/tests/action_d/test_badips.py +++ b/fail2ban/tests/action_d/test_badips.py @@ -61,6 +61,7 @@ if sys.version_info >= (2,7): # pragma: no cover - may be unavailable # Must cancel timer! if self.action._timer: self.action._timer.cancel() + super(BadIPsActionTest, self).tearDown() def testCategory(self): categories = self.action.getCategories() diff --git a/fail2ban/tests/action_d/test_smtp.py b/fail2ban/tests/action_d/test_smtp.py index bf8e83a2..d262f73e 100644 --- a/fail2ban/tests/action_d/test_smtp.py +++ b/fail2ban/tests/action_d/test_smtp.py @@ -81,6 +81,7 @@ class SMTPActionTest(unittest.TestCase): self.smtpd.close() self._active = False self._loop_thread.join() + super(SMTPActionTest, self).tearDown() def _exec_and_wait(self, doaction, timeout=3, short=False): if short: timeout /= 25 diff --git a/fail2ban/tests/banmanagertestcase.py b/fail2ban/tests/banmanagertestcase.py index da454ec3..2436babf 100644 --- a/fail2ban/tests/banmanagertestcase.py +++ b/fail2ban/tests/banmanagertestcase.py @@ -41,6 +41,7 @@ class AddFailure(unittest.TestCase): def tearDown(self): """Call after every test case.""" + super(AddFailure, self).tearDown() tearDownMyTime() def testAdd(self): @@ -169,6 +170,7 @@ class StatusExtendedCymruInfo(unittest.TestCase): def tearDown(self): """Call after every test case.""" + super(StatusExtendedCymruInfo, self).tearDown() tearDownMyTime() available = True, None diff --git a/fail2ban/tests/clientbeautifiertestcase.py b/fail2ban/tests/clientbeautifiertestcase.py index 7d20e84e..79a0ff54 100644 --- a/fail2ban/tests/clientbeautifiertestcase.py +++ b/fail2ban/tests/clientbeautifiertestcase.py @@ -37,6 +37,7 @@ class BeautifierTest(unittest.TestCase): def tearDown(self): """ Call after every test case """ + super(BeautifierTest, self).tearDown() def testGetInputCmd(self): cmd = ["test"] diff --git a/fail2ban/tests/failmanagertestcase.py b/fail2ban/tests/failmanagertestcase.py index 9de4ced6..ad89ec76 100644 --- a/fail2ban/tests/failmanagertestcase.py +++ b/fail2ban/tests/failmanagertestcase.py @@ -42,7 +42,8 @@ class AddFailure(unittest.TestCase): def tearDown(self): """Call after every test case.""" - + super(AddFailure, self).tearDown() + def _addDefItems(self): self.__items = [[u'193.168.0.128', 1167605999.0], [u'193.168.0.128', 1167605999.0], diff --git a/fail2ban/tests/filtertestcase.py b/fail2ban/tests/filtertestcase.py index 2b35edc9..d3217555 100644 --- a/fail2ban/tests/filtertestcase.py +++ b/fail2ban/tests/filtertestcase.py @@ -478,7 +478,7 @@ class LogFileFilterPoll(unittest.TestCase): def tearDown(self): """Call after every test case.""" - pass + super(LogFileFilterPoll, self).tearDown() #def testOpen(self): # self.filter.openLogFile(LogFile.FILENAME) @@ -861,7 +861,7 @@ def get_monitor_failures_testcase(Filter_): #print "D: KILLING THE FILE" _killfile(self.file, self.name) #time.sleep(0.2) # Give FS time to ack the removal - pass + super(MonitorFailures, self).tearDown() def _sleep_4_poll(self): # Since FilterPoll relies on time stamps and some @@ -1076,7 +1076,7 @@ def get_monitor_failures_journal_testcase(Filter_): # pragma: systemd no cover if self.filter and self.filter.active: self.filter.stop() self.filter.join() # wait for the thread to terminate - pass + super(MonitorJournalFailures, self).tearDown() def _getRuntimeJournal(self): # retrieve current system journal path diff --git a/fail2ban/tests/samplestestcase.py b/fail2ban/tests/samplestestcase.py index 96e0b21c..1d33cc44 100644 --- a/fail2ban/tests/samplestestcase.py +++ b/fail2ban/tests/samplestestcase.py @@ -54,6 +54,7 @@ class FilterSamplesRegex(unittest.TestCase): def tearDown(self): """Call after every test case.""" + super(FilterSamplesRegex, self).tearDown() tearDownMyTime() def testFiltersPresent(self): diff --git a/fail2ban/tests/servertestcase.py b/fail2ban/tests/servertestcase.py index 151f443b..0bbbbe8f 100644 --- a/fail2ban/tests/servertestcase.py +++ b/fail2ban/tests/servertestcase.py @@ -79,7 +79,7 @@ class TransmitterBase(unittest.TestCase): """Call after every test case.""" # stop jails, etc. self.server.quit() - #super(TransmitterBase, self).tearDown() + super(TransmitterBase, self).tearDown() def setGetTest(self, cmd, inValue, outValue=(None,), outCode=0, jail=None, repr_=False): """Process set/get commands and compare both return values diff --git a/fail2ban/tests/utils.py b/fail2ban/tests/utils.py index 23c52a43..8c7db688 100644 --- a/fail2ban/tests/utils.py +++ b/fail2ban/tests/utils.py @@ -535,12 +535,21 @@ if True: ## if not hasattr(unittest.TestCase, 'assertIn'): _org_setUp = unittest.TestCase.setUp def _customSetUp(self): # print('=='*10, self) - if unittest.F2B.log_level <= logging.DEBUG: # so if DEBUG etc -- show them (and log it in travis)! - print("") + # so if DEBUG etc -- show them (and log it in travis)! + if unittest.F2B.log_level <= logging.DEBUG: # pragma: no cover + sys.stderr.write("\n") logSys.debug('='*10 + ' %s ' + '='*20, self.id()) _org_setUp(self) + if unittest.F2B.verbosity > 2: # pragma: no cover + self.__startTime = time.time() + +_org_tearDown = unittest.TestCase.tearDown +def _customTearDown(self): + if unittest.F2B.verbosity > 2: # pragma: no cover + sys.stderr.write(" %.3fs -- " % (time.time() - self.__startTime,)) unittest.TestCase.setUp = _customSetUp +unittest.TestCase.tearDown = _customTearDown class LogCaptureTestCase(unittest.TestCase):