mirror of
https://github.com/fail2ban/fail2ban.git
synced 2026-03-11 08:55:31 +00:00
Test cases fixed:
testFail2BanExceptHook - use local sys.__excepthook__ to check was really executed and prevent write error in stderr.
This commit is contained in:
parent
518cc92ccc
commit
8dbc04aa06
1 changed files with 7 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue