mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-05 16:08:40 +00:00
[Tests] Catch and print errors in setup/teardown
This commit is contained in:
parent
fc6672adda
commit
374989a2ad
2 changed files with 18 additions and 3 deletions
|
@ -19,16 +19,26 @@ class BaseTestCase(unittest.TestCase):
|
||||||
warnings.warn("The component._ComponentRegistry.components is not empty on test setup."
|
warnings.warn("The component._ComponentRegistry.components is not empty on test setup."
|
||||||
"This is probably caused by another test that didn't clean up after finishing!: %s" %
|
"This is probably caused by another test that didn't clean up after finishing!: %s" %
|
||||||
component._ComponentRegistry.components)
|
component._ComponentRegistry.components)
|
||||||
return self.set_up()
|
d = maybeDeferred(self.set_up)
|
||||||
|
|
||||||
|
def on_setup_error(error):
|
||||||
|
warnings.warn("Error caught in test setup!\n%s" % error.getTraceback())
|
||||||
|
self.fail()
|
||||||
|
|
||||||
|
return d.addErrback(on_setup_error)
|
||||||
|
|
||||||
def tearDown(self): # NOQA
|
def tearDown(self): # NOQA
|
||||||
d = maybeDeferred(self.tear_down)
|
d = maybeDeferred(self.tear_down)
|
||||||
|
|
||||||
def on_teared_down(result):
|
def on_teardown_failed(error):
|
||||||
|
warnings.warn("Error caught in test teardown!\n%s" % error.getTraceback())
|
||||||
|
self.fail()
|
||||||
|
|
||||||
|
def on_teardown_complete(result):
|
||||||
component._ComponentRegistry.components.clear()
|
component._ComponentRegistry.components.clear()
|
||||||
component._ComponentRegistry.dependents.clear()
|
component._ComponentRegistry.dependents.clear()
|
||||||
|
|
||||||
return d.addCallback(on_teared_down)
|
return d.addCallbacks(on_teardown_complete, on_teardown_failed)
|
||||||
|
|
||||||
def set_up(self):
|
def set_up(self):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -82,8 +82,13 @@ class Auth(JSONComponent):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Auth, self).__init__("Auth")
|
super(Auth, self).__init__("Auth")
|
||||||
self.worker = LoopingCall(self._clean_sessions)
|
self.worker = LoopingCall(self._clean_sessions)
|
||||||
|
|
||||||
|
def start(self):
|
||||||
self.worker.start(5)
|
self.worker.start(5)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
self.worker.stop()
|
||||||
|
|
||||||
def _clean_sessions(self):
|
def _clean_sessions(self):
|
||||||
config = component.get("DelugeWeb").config
|
config = component.get("DelugeWeb").config
|
||||||
session_ids = config["sessions"].keys()
|
session_ids = config["sessions"].keys()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue