fix issue148 - recognize @unittest.skip on classes, avoid setup/teardown
This commit is contained in:
parent
ba9b27fcd3
commit
7e831b66ec
|
@ -10,6 +10,8 @@ Changes between 2.3.2 and 2.3.3.dev
|
||||||
|
|
||||||
- fix issue215 - split test_python.org into multiple files
|
- fix issue215 - split test_python.org into multiple files
|
||||||
|
|
||||||
|
- fix issue148 - @unittest.skip on classes is now recognized and avoids
|
||||||
|
calling setUpClass/tearDownClass
|
||||||
|
|
||||||
Changes between 2.3.1 and 2.3.2
|
Changes between 2.3.1 and 2.3.2
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
|
@ -46,12 +46,16 @@ class UnitTestCase(pytest.Class):
|
||||||
yield TestCaseFunction('runTest', parent=self)
|
yield TestCaseFunction('runTest', parent=self)
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
|
if getattr(self.obj, '__unittest_skip__', False):
|
||||||
|
return
|
||||||
meth = getattr(self.obj, 'setUpClass', None)
|
meth = getattr(self.obj, 'setUpClass', None)
|
||||||
if meth is not None:
|
if meth is not None:
|
||||||
meth()
|
meth()
|
||||||
super(UnitTestCase, self).setup()
|
super(UnitTestCase, self).setup()
|
||||||
|
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
|
if getattr(self.obj, '__unittest_skip__', False):
|
||||||
|
return
|
||||||
meth = getattr(self.obj, 'tearDownClass', None)
|
meth = getattr(self.obj, 'tearDownClass', None)
|
||||||
if meth is not None:
|
if meth is not None:
|
||||||
meth()
|
meth()
|
||||||
|
|
|
@ -96,6 +96,25 @@ def test_teardown(testdir):
|
||||||
assert passed == 2
|
assert passed == 2
|
||||||
assert passed + skipped + failed == 2
|
assert passed + skipped + failed == 2
|
||||||
|
|
||||||
|
@pytest.mark.skipif("sys.version_info < (3,1)")
|
||||||
|
def test_unittest_skip_issue148(testdir):
|
||||||
|
testpath = testdir.makepyfile("""
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
@unittest.skip("hello")
|
||||||
|
class MyTestCase(unittest.TestCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(self):
|
||||||
|
xxx
|
||||||
|
def test_one(self):
|
||||||
|
pass
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(self):
|
||||||
|
xxx
|
||||||
|
""")
|
||||||
|
reprec = testdir.inline_run(testpath)
|
||||||
|
reprec.assertoutcome(skipped=1)
|
||||||
|
|
||||||
def test_method_and_teardown_failing_reporting(testdir):
|
def test_method_and_teardown_failing_reporting(testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import unittest, pytest
|
import unittest, pytest
|
||||||
|
|
Loading…
Reference in New Issue