Commits

Anonymous committed 03762be

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

Comments (0)

Files changed (2)

py/_plugin/pytest_nose.py

 
 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()

testing/plugin/test_pytest_nose.py

     ])
 
 
+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