Commit 5e6c9f89 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[1451] apply second patch

parent f3559fa1
......@@ -102,46 +102,31 @@ class TestMain(unittest.TestCase):
ddns.main(self._server)
self.assertTrue(self._server.run_called)
def test_exceptions(self):
'''
Test whether exceptions are caught in main()
These exceptions should not bubble up.
def check_exception(self, ex):
'''Common test sequence to see if the given exception is caused.
'''
self._server.set_exception(KeyboardInterrupt())
self.assertFalse(self._server.exception_raised)
ddns.main(self._server)
self.assertTrue(self._server.exception_raised)
# Should technically not be necessary, but reset server to be sure
self._server.reset()
self.assertFalse(self._server.exception_raised)
self._server.set_exception(isc.cc.SessionError("error"))
ddns.main(self._server)
self.assertTrue(self._server.exception_raised)
self._server.reset()
self.assertFalse(self._server.exception_raised)
self._server.set_exception(isc.config.ModuleCCSessionError("error"))
ddns.main(self._server)
self.assertTrue(self._server.exception_raised)
self._server.reset()
self.assertFalse(self._server.exception_raised)
self._server.set_exception(ddns.DDNSConfigError("error"))
self._server.set_exception(ex)
ddns.main(self._server)
self.assertTrue(self._server.exception_raised)
self._server.reset()
def test_exceptions(self):
'''
Test whether exceptions are caught in main()
These exceptions should not bubble up.
'''
self._server.set_exception(KeyboardInterrupt())
self.assertFalse(self._server.exception_raised)
self._server.set_exception(isc.cc.SessionTimeout("error"))
ddns.main(self._server)
self.assertTrue(self._server.exception_raised)
self._server.reset()
self.assertFalse(self._server.exception_raised)
self._server.set_exception(Exception("error"))
ddns.main(self._server)
self.assertTrue(self._server.exception_raised)
self.check_exception(isc.cc.SessionError("error"))
self.check_exception(isc.config.ModuleCCSessionError("error"))
self.check_exception(ddns.DDNSConfigError("error"))
self.check_exception(isc.cc.SessionTimeout("error"))
self.check_exception(Exception("error"))
# Add one that is not a subclass of Exception, and hence not
# caught. Misuse BaseException for that.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment