From 48c2cbfa0b02ea9e3a22d22c71d20b5e8277e445 Mon Sep 17 00:00:00 2001 From: sebres Date: Wed, 4 Jul 2018 17:05:36 +0200 Subject: [PATCH] improve failure-message of assertNotLogged in case of single match given --- fail2ban/tests/misctestcase.py | 4 +++- fail2ban/tests/utils.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fail2ban/tests/misctestcase.py b/fail2ban/tests/misctestcase.py index adf7886b..5f0e70e4 100644 --- a/fail2ban/tests/misctestcase.py +++ b/fail2ban/tests/misctestcase.py @@ -304,8 +304,10 @@ class TestsUtilsTest(LogCaptureTestCase): ## assertLogged, assertNotLogged negative case: self.pruneLog() logSys.debug('test "xyz"') - self._testAssertionErrorRE(r"All of the .* were found present in the log", + self._testAssertionErrorRE(r".* was found in the log", self.assertNotLogged, 'test "xyz"') + self._testAssertionErrorRE(r"All of the .* were found present in the log", + self.assertNotLogged, 'test "xyz"', 'test') self._testAssertionErrorRE(r"was found in the log", self.assertNotLogged, 'test', 'xyz', all=True) self._testAssertionErrorRE(r"was not found in the log", diff --git a/fail2ban/tests/utils.py b/fail2ban/tests/utils.py index 27229b69..5c398ca9 100644 --- a/fail2ban/tests/utils.py +++ b/fail2ban/tests/utils.py @@ -807,7 +807,7 @@ class LogCaptureTestCase(unittest.TestCase): all : boolean (default False) if True should fail if any of s logged """ logged = self._log.getvalue() - if not kwargs.get('all', False): + if len(s) > 1 and not kwargs.get('all', False): for s_ in s: if s_ not in logged: return