summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Dechaume <boolegue@gmail.com>2014-03-18 15:06:41 +0100
committerJohn Szakmeister <john@szakmeister.net>2014-04-10 09:20:10 -0400
commite49dddb4eb3a3f6fa9d910e1e34bde02eaba5f18 (patch)
treeff95cd68da24591204edad7aa474822567d00e0b
parent4a610dadb26c3c2f5ca7946fe5645faf5d9f070f (diff)
downloadnose-e49dddb4eb3a3f6fa9d910e1e34bde02eaba5f18.tar.gz
Fix #786: generator method fails with callable instance
-rw-r--r--nose/loader.py4
-rw-r--r--unit_tests/test_issue_786.py12
2 files changed, 14 insertions, 2 deletions
diff --git a/nose/loader.py b/nose/loader.py
index 4152a12..8a85515 100644
--- a/nose/loader.py
+++ b/nose/loader.py
@@ -287,7 +287,7 @@ class TestLoader(unittest.TestLoader):
test_func = unbound_method(c, getattr(c, test_func))
if ismethod(test_func):
yield MethodTestCase(test_func, arg=arg, descriptor=g)
- elif isfunction(test_func):
+ elif callable(test_func):
# In this case we're forcing the 'MethodTestCase'
# to run the inline function as its test call,
# but using the generator method as the 'method of
@@ -296,7 +296,7 @@ class TestLoader(unittest.TestLoader):
else:
yield Failure(
TypeError,
- "%s is not a function or method" % test_func)
+ "%s is not a callable or method" % test_func)
except KeyboardInterrupt:
raise
except:
diff --git a/unit_tests/test_issue_786.py b/unit_tests/test_issue_786.py
new file mode 100644
index 0000000..5669be4
--- /dev/null
+++ b/unit_tests/test_issue_786.py
@@ -0,0 +1,12 @@
+def test_evens():
+ yield check_even_cls
+
+class Test(object):
+ def test_evens(self):
+ yield check_even_cls
+
+class Check(object):
+ def __call__(self):
+ pass
+
+check_even_cls = Check()