summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2007-04-16 09:19:04 +0200
committerAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2007-04-16 09:19:04 +0200
commitcbc29a8ad8631cb3c2ef98f042f1fd8242d552e4 (patch)
treefce8441f943b6fcc3e93867735c92fcdde43ad68
parent230e54d8944a7433f55980a347dac76c22cbc51d (diff)
downloadlogilab-common-cbc29a8ad8631cb3c2ef98f042f1fd8242d552e4.tar.gz
added ability to explicitly set the test description. This can be useful for failure reports on generative tests
-rw-r--r--testlib.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/testlib.py b/testlib.py
index 699f759..e849ae3 100644
--- a/testlib.py
+++ b/testlib.py
@@ -778,7 +778,26 @@ class TestCase(unittest.TestCase):
self._captured_stderr = ""
self._out = []
self._err = []
-
+ self._current_test_descr = None
+
+
+ def set_description(self, descr):
+ """sets the current test's description.
+ This can be useful for generative tests because it allows to specify
+ a description per yield
+ """
+ self._current_test_descr = descr
+
+ # override default's unittest.py feature
+ def shortDescription(self):
+ """override default unitest shortDescription to handle correctly
+ generative tests
+ """
+ if self._current_test_descr is not None:
+ return self._current_test_descr
+ return super(TestCase, self).shortDescription()
+
+
def captured_output(self):
return self._captured_stdout.strip(), self._captured_stderr.strip()