From 40a55a640c0448301c12c1d1549353ae02565e09 Mon Sep 17 00:00:00 2001 From: ataumoefolau Date: Fri, 12 Oct 2012 14:39:17 +1000 Subject: [PATCH 1/2] nose.py: don't try to call setup if it's not callable --- _pytest/nose.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_pytest/nose.py b/_pytest/nose.py index cde916400..ffa186923 100644 --- a/_pytest/nose.py +++ b/_pytest/nose.py @@ -41,7 +41,7 @@ def pytest_make_collect_report(collector): def call_optional(obj, name): method = getattr(obj, name, None) - if method is not None and not hasattr(method, "_pytestfixturefunction"): + if method is not None and not hasattr(method, "_pytestfixturefunction") and callable(method): # If there's any problems allow the exception to raise rather than # silently ignoring them method() From 04754f6748ed93b3103a4fb8e7cbec746c06ef72 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Mon, 5 Nov 2012 21:17:58 +0100 Subject: [PATCH 2/2] test call_optional not calling non-callable functions --- testing/test_nose.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/testing/test_nose.py b/testing/test_nose.py index f67f6cb73..0fe420f3f 100644 --- a/testing/test_nose.py +++ b/testing/test_nose.py @@ -35,6 +35,12 @@ def test_setup_func_with_setup_decorator(): assert not l +def test_setup_func_not_callable(): + from _pytest.nose import call_optional + class A: + f = 1 + call_optional(A(), "f") + def test_nose_setup_func(testdir): p = testdir.makepyfile(""" from nose.tools import with_setup