summaryrefslogtreecommitdiff
path: root/testlib.py
diff options
context:
space:
mode:
authorDenis Laxalde <denis.laxalde@logilab.fr>2014-06-05 10:06:59 +0200
committerDenis Laxalde <denis.laxalde@logilab.fr>2014-06-05 10:06:59 +0200
commitb0f384ef4bb2d7e5ac419320c73199b0aed65ee7 (patch)
tree7cee5f5ca7f8d7947a93ed6764ecab14bedd7591 /testlib.py
parent86dc908ee0df6f8bf9a0bd11d9952dcaba0689e4 (diff)
downloadlogilab-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.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/testlib.py b/testlib.py
index 817149c..683c7ac 100644
--- a/testlib.py
+++ b/testlib.py
@@ -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)