fix issue473: work around mock putting an unbound method into a class

dict when double-patching.

--HG--
branch : issue473
This commit is contained in:
holger krekel
2014-04-08 12:50:13 +02:00
parent ef7cb47b1e
commit f91049cec9
3 changed files with 20 additions and 0 deletions

View File

@@ -222,6 +222,8 @@ def pytest_pycollect_makeitem(__multicall__, collector, name, obj):
return Class(name, parent=collector)
elif collector.funcnamefilter(name) and hasattr(obj, "__call__") and \
getfixturemarker(obj) is None:
# mock seems to store unbound methods (issue473), let's normalize it
obj = getattr(obj, "__func__", obj)
if not isfunction(obj):
collector.warn(code="C2", message=
"cannot collect %r because it is not a function."