From cae8a184371f64819ddd3e3d33759be8c4f61de3 Mon Sep 17 00:00:00 2001 From: bendikro Date: Wed, 30 Dec 2015 22:35:42 +0100 Subject: [PATCH] [Tests] Fixes to improve terminal output from unit tests Add __str__ to WrappedException so that the stacktrace is printed when a unit test raises a WrappedException. Change the log output from error to warning in DelugeRPCProtocol.dispatch when sending back a raised exception on an RPC request. --- deluge/core/rpcserver.py | 6 +++--- deluge/error.py | 3 +++ deluge/tests/basetest.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/deluge/core/rpcserver.py b/deluge/core/rpcserver.py index 33bdd8261..7aeb42f32 100644 --- a/deluge/core/rpcserver.py +++ b/deluge/core/rpcserver.py @@ -215,9 +215,9 @@ class DelugeRPCProtocol(DelugeTransferProtocol): )) except AttributeError: # This is not a deluge exception (object has no attribute '_args), let's wrap it - log.error("An exception occurred while sending RPC_ERROR to " - "client. Wrapping it and resending. Error to " - "send(causing exception goes next):\n%s", formated_tb) + log.warning("An exception occurred while sending RPC_ERROR to " + "client. Wrapping it and resending. Error to " + "send(causing exception goes next):\n%s", formated_tb) try: raise WrappedException(str(exceptionValue), exceptionType.__name__, formated_tb) except WrappedException: diff --git a/deluge/error.py b/deluge/error.py index 8a75b6040..ed758fecb 100644 --- a/deluge/error.py +++ b/deluge/error.py @@ -43,6 +43,9 @@ class WrappedException(DelugeError): self.type = exception_type self.traceback = traceback + def __str__(self): + return "%s\n%s" % (self.message, self.traceback) + class _ClientSideRecreateError(DelugeError): pass diff --git a/deluge/tests/basetest.py b/deluge/tests/basetest.py index c9e6df22d..d32532019 100644 --- a/deluge/tests/basetest.py +++ b/deluge/tests/basetest.py @@ -16,7 +16,7 @@ class BaseTestCase(unittest.TestCase): def setUp(self): # NOQA if len(component._ComponentRegistry.components) != 0: - warnings.warn("The component._ComponentRegistry.components is not empty on test setup." + warnings.warn("The component._ComponentRegistry.components is not empty on test setup.\n" "This is probably caused by another test that didn't clean up after finishing!: %s" % component._ComponentRegistry.components) d = maybeDeferred(self.set_up)