diff options
author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> | 2007-04-16 09:19:04 +0200 |
---|---|---|
committer | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> | 2007-04-16 09:19:04 +0200 |
commit | cbc29a8ad8631cb3c2ef98f042f1fd8242d552e4 (patch) | |
tree | fce8441f943b6fcc3e93867735c92fcdde43ad68 | |
parent | 230e54d8944a7433f55980a347dac76c22cbc51d (diff) | |
download | logilab-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.py | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -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() |