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:
parent
f814cb5346
commit
a2f9fbb178
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue