diff --git a/py/_plugin/pytest_nose.py b/py/_plugin/pytest_nose.py index 660b5f8ae..91e6e79b1 100644 --- a/py/_plugin/pytest_nose.py +++ b/py/_plugin/pytest_nose.py @@ -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() diff --git a/testing/plugin/test_pytest_nose.py b/testing/plugin/test_pytest_nose.py index 199561cf7..3b049471e 100644 --- a/testing/plugin/test_pytest_nose.py +++ b/testing/plugin/test_pytest_nose.py @@ -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