take the skip property of unittest cases and functions into account
This commit is contained in:
parent
96cb1208d3
commit
b28977fbaf
|
@ -31,6 +31,7 @@ Changes between 2.1.3 and 2.2.0
|
||||||
- fix compatibility with twisted/trial-11.1.0 use cases
|
- fix compatibility with twisted/trial-11.1.0 use cases
|
||||||
- simplify Node.listchain
|
- simplify Node.listchain
|
||||||
- simplify junitxml output code by relying on py.xml
|
- simplify junitxml output code by relying on py.xml
|
||||||
|
- add support for skip properties on unittest classes and functions
|
||||||
|
|
||||||
Changes between 2.1.2 and 2.1.3
|
Changes between 2.1.2 and 2.1.3
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
|
@ -46,6 +46,10 @@ class TestCaseFunction(pytest.Function):
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self._testcase = self.parent.obj(self.name)
|
self._testcase = self.parent.obj(self.name)
|
||||||
self._obj = getattr(self._testcase, self.name)
|
self._obj = getattr(self._testcase, self.name)
|
||||||
|
if hasattr(self._testcase, 'skip'):
|
||||||
|
pytest.skip(self._testcase.skip)
|
||||||
|
if hasattr(self._obj, 'skip'):
|
||||||
|
pytest.skip(self._obj.skip)
|
||||||
if hasattr(self._testcase, 'setup_method'):
|
if hasattr(self._testcase, 'setup_method'):
|
||||||
self._testcase.setup_method(self._obj)
|
self._testcase.setup_method(self._obj)
|
||||||
|
|
||||||
|
|
|
@ -232,6 +232,29 @@ def test_module_level_pytestmark(testdir):
|
||||||
reprec.assertoutcome(skipped=1)
|
reprec.assertoutcome(skipped=1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_testcase_skip_property(testdir):
|
||||||
|
testpath = testdir.makepyfile("""
|
||||||
|
import unittest
|
||||||
|
class MyTestCase(unittest.TestCase):
|
||||||
|
skip = 'dont run'
|
||||||
|
def test_func(self):
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
reprec = testdir.inline_run(testpath, "-s")
|
||||||
|
reprec.assertoutcome(skipped=1)
|
||||||
|
|
||||||
|
def test_testfunction_skip_property(testdir):
|
||||||
|
testpath = testdir.makepyfile("""
|
||||||
|
import unittest
|
||||||
|
class MyTestCase(unittest.TestCase):
|
||||||
|
def test_func(self):
|
||||||
|
pass
|
||||||
|
test_func.skip = 'dont run'
|
||||||
|
""")
|
||||||
|
reprec = testdir.inline_run(testpath, "-s")
|
||||||
|
reprec.assertoutcome(skipped=1)
|
||||||
|
|
||||||
|
|
||||||
class TestTrialUnittest:
|
class TestTrialUnittest:
|
||||||
def setup_class(cls):
|
def setup_class(cls):
|
||||||
pytest.importorskip("twisted.trial.unittest")
|
pytest.importorskip("twisted.trial.unittest")
|
||||||
|
|
Loading…
Reference in New Issue