add test_unittest_style_setup_teardown()

to test setUpModule() and tearDownModule()
This commit is contained in:
Brian Okken 2013-06-22 09:35:10 -07:00
parent 3bcd3317ad
commit 5e77eb23eb
1 changed files with 22 additions and 0 deletions

View File

@ -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