diff --git a/_pytest/unittest.py b/_pytest/unittest.py index 3f059bf12..28353f4f8 100644 --- a/_pytest/unittest.py +++ b/_pytest/unittest.py @@ -26,11 +26,13 @@ class UnitTestCase(pytest.Class): meth = getattr(self.obj, 'setUpClass', None) if meth is not None: meth() + super(UnitTestCase, self).setup() def teardown(self): meth = getattr(self.obj, 'tearDownClass', None) if meth is not None: meth() + super(UnitTestCase, self).teardown() class TestCaseFunction(pytest.Function): _excinfo = None diff --git a/pytest.py b/pytest.py index 6f8b74c6a..d2c9120c1 100644 --- a/pytest.py +++ b/pytest.py @@ -5,7 +5,7 @@ see http://pytest.org for documentation and details (c) Holger Krekel and others, 2004-2010 """ -__version__ = '2.0.0.dev35' +__version__ = '2.0.0.dev36' __all__ = ['main'] from _pytest.core import main, UsageError, _preloadplugins diff --git a/setup.py b/setup.py index 3730425ca..5a83a9d3b 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def main(): name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.0.0.dev35', + version='2.0.0.dev36', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff --git a/testing/test_unittest.py b/testing/test_unittest.py index cd6c6295c..ecd0b6131 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -82,7 +82,7 @@ def test_module_level_pytestmark(testdir): reprec = testdir.inline_run(testpath, "-s") reprec.assertoutcome(skipped=1) -def test_class_setup(testdir): +def test_setup_setUpClass(testdir): testpath = testdir.makepyfile(""" import unittest import pytest @@ -104,6 +104,26 @@ def test_class_setup(testdir): reprec = testdir.inline_run(testpath) reprec.assertoutcome(passed=3) +def test_setup_class(testdir): + testpath = testdir.makepyfile(""" + import unittest + import pytest + class MyTestCase(unittest.TestCase): + x = 0 + def setup_class(cls): + cls.x += 1 + def test_func1(self): + assert self.x == 1 + def test_func2(self): + assert self.x == 1 + def teardown_class(cls): + cls.x -= 1 + def test_teareddown(): + assert MyTestCase.x == 0 + """) + reprec = testdir.inline_run(testpath) + reprec.assertoutcome(passed=3) + @pytest.mark.multi(type=['Error', 'Failure']) def test_testcase_adderrorandfailure_defers(testdir, type):