From 62e54424a7d6e3e196676e0a991b6dd878ae7104 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Mon, 16 Dec 2013 23:12:00 +0000 Subject: [PATCH] TST: flushLog to run correctly regardless of user/travis instigated logging level --- fail2ban/tests/servertestcase.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/fail2ban/tests/servertestcase.py b/fail2ban/tests/servertestcase.py index a7696efd..26ff8e0a 100644 --- a/fail2ban/tests/servertestcase.py +++ b/fail2ban/tests/servertestcase.py @@ -680,14 +680,24 @@ class TransmitterLogging(TransmitterBase): l.warn("After flushlogs") with open(fn2,'r') as f: line1 = f.next() - #print line1 + if line1.find('Changed logging target to') >= 0: + line1 = f.next() self.assertTrue(line1.endswith("Before file moved\n")) line2 = f.next() - #print line2 self.assertTrue(line2.endswith("After file moved\n")) - self.assertRaises(StopIteration, f.next) + try: + n = f.next() + if n.find("Command: ['flushlogs']") >=0: + self.assertRaises(StopIteration, f.next) + else: + self.fail("Exception StopIteration or Command: ['flushlogs'] expected. Got: %s" % n) + except StopIteration: + pass # on higher debugging levels this is expected with open(fn,'r') as f: - self.assertTrue(f.next().endswith("After flushlogs\n")) + line1 = f.next() + if line1.find('rollover performed on') >= 0: + line1 = f.next() + self.assertTrue(line1.endswith("After flushlogs\n")) self.assertRaises(StopIteration, f.next) finally: os.remove(fn2)