Test cases fixed:

testFail2BanExceptHook - use local sys.__excepthook__ to check was really executed and prevent write error in stderr.
pull/839/head
sebres 2014-10-29 13:30:24 +01:00
parent 518cc92ccc
commit 8dbc04aa06
1 changed files with 7 additions and 1 deletions

View File

@ -804,7 +804,7 @@ class RegexTests(unittest.TestCase):
class _BadThread(JailThread):
def run(self):
int("ignore this exception -- raised for testing")
raise RuntimeError('run bad thread exception')
class LoggingTests(LogCaptureTestCase):
@ -814,7 +814,13 @@ class LoggingTests(LogCaptureTestCase):
self.assertEqual(testLogSys.name, "fail2ban.name")
def testFail2BanExceptHook(self):
prev_exchook = sys.__excepthook__
x = []
sys.__excepthook__ = lambda *args: x.append(args)
badThread = _BadThread()
badThread.start()
badThread.join()
self.assertTrue(self._is_logged("Unhandled exception"))
sys.__excepthook__ = prev_exchook
self.assertEqual(len(x), 1)
self.assertEqual(x[0][0], RuntimeError)