add test_unittest_style_setup_teardown()
to test setUpModule() and tearDownModule()
This commit is contained in:
parent
3bcd3317ad
commit
5e77eb23eb
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue