Added a test and fix for nose compatible setup/teardown functions that contain a variable

--HG--
branch : trunk
This commit is contained in:
Ed Singleton 2010-09-03 10:04:45 +01:00
parent d8fcc96563
commit faf0fe8887
2 changed files with 27 additions and 1 deletions

View File

@ -93,6 +93,6 @@ def call_optional(obj, name):
if method:
ismethod = inspect.ismethod(method)
rawcode = py.code.getrawcode(method)
if not rawcode.co_varnames[ismethod:]:
if not rawcode.co_varnames[ismethod:rawcode.co_argcount]:
method()
return True

View File

@ -17,6 +17,32 @@ def test_nose_setup(testdir):
"*2 passed*"
])
def test_nose_setup_func(testdir):
p = testdir.makepyfile("""
l = []
def my_setup():
a = 1
l.append(a)
def my_teardown():
b = 2
l.append(b)
def test_hello():
print l
assert l == [1]
def test_world():
print l
assert l == [1,2]
test_hello.setup = my_setup
test_hello.teardown = my_teardown
""")
result = testdir.runpytest(p, '-p', 'nose')
result.stdout.fnmatch_lines([
"*2 passed*"
])
def test_nose_test_generator_fixtures(testdir):
p = testdir.makepyfile("""
# taken from nose-0.11.1 unit_tests/test_generator_fixtures.py