diff options
author | Denis Laxalde <denis.laxalde@logilab.fr> | 2014-06-05 10:06:59 +0200 |
---|---|---|
committer | Denis Laxalde <denis.laxalde@logilab.fr> | 2014-06-05 10:06:59 +0200 |
commit | b0f384ef4bb2d7e5ac419320c73199b0aed65ee7 (patch) | |
tree | 7cee5f5ca7f8d7947a93ed6764ecab14bedd7591 /testlib.py | |
parent | 86dc908ee0df6f8bf9a0bd11d9952dcaba0689e4 (diff) | |
download | logilab-common-b0f384ef4bb2d7e5ac419320c73199b0aed65ee7.tar.gz |
[testlib] Handle skip methods as in unittest
Just copied this piece of code from unittest.TestCase.run which:
* makes it possible to skip whole TestCase (using class decorator),
* handle conditional skip (skipIf).
As an aside, with this, setUp() is not executed anymore when a test is
skipped.
Closes #252838.
Diffstat (limited to 'testlib.py')
-rw-r--r-- | testlib.py | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -579,6 +579,16 @@ class TestCase(unittest.TestCase): # if result.cvg: # result.cvg.start() testMethod = self._get_test_method() + if (getattr(self.__class__, "__unittest_skip__", False) or + getattr(testMethod, "__unittest_skip__", False)): + # If the class or method was skipped. + try: + skip_why = (getattr(self.__class__, '__unittest_skip_why__', '') + or getattr(testMethod, '__unittest_skip_why__', '')) + self._addSkip(result, skip_why) + finally: + result.stopTest(self) + return if runcondition and not runcondition(testMethod): return # test is skipped result.startTest(self) |