diff --git a/testing/test_unittest.py b/testing/test_unittest.py index eecc9da68..74c499939 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -65,6 +65,28 @@ def test_setup(testdir): rep = reprec.matchreport("test_both", when="teardown") assert rep.failed and '42' in str(rep.longrepr) +def test_unittest_style_setup_teardown(testdir): + testdir.makepyfile(""" + l = [] + + def setUpModule(): + l.append(1) + + def tearDownModule(): + del l[0] + + def test_hello(): + assert l == [1] + + def test_world(): + assert l == [1] + """) + result = testdir.runpytest('-p', 'nose') + result.stdout.fnmatch_lines([ + "*2 passed*", + ]) + + def test_new_instances(testdir): testpath = testdir.makepyfile(""" import unittest