Added a test and fix for nose compatible setup/teardown functions so that even less errors are ignored

--HG--
branch : trunk
This commit is contained in:
Ed Singleton 2010-09-03 11:32:12 +01:00
parent f814cb5346
commit a2f9fbb178
2 changed files with 25 additions and 1 deletions

View File

@ -90,7 +90,7 @@ def pytest_make_collect_report(collector):
def call_optional(obj, name):
method = getattr(obj, name, None)
if method and callable(method):
if method:
# If there's any problems allow the exception to raise rather than
# silently ignoring them
method()

View File

@ -74,6 +74,30 @@ def test_nose_setup_func_failure(testdir):
])
def test_nose_setup_func_failure_2(testdir):
p = testdir.makepyfile("""
l = []
my_setup = 1
my_teardown = 2
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([
"*TypeError: 'int' object is not callable*"
])
def test_nose_setup_partial(testdir):
p = testdir.makepyfile("""
from functools import partial