From 45693c28470f5a0e2c93d5ca6db130e2c27fdfaa Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Sun, 19 Aug 2012 14:57:07 +0200 Subject: [PATCH] exchange the rawcode factory marker check with a more robust and specific instance check as advised by holger --- _pytest/python.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/_pytest/python.py b/_pytest/python.py index 7dd356001..6e1841605 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -1308,16 +1308,14 @@ class FuncargManager: obj = getattr(holderobj, name) if not callable(obj): continue - # to avoid breaking on magic global callables - # we explicitly check if we get a sane code object - # else having mock.call in the globals fails for example - code = py.code.getrawcode(obj) - if not inspect.iscode(code): - continue # resource factories either have a pytest_funcarg__ prefix # or are "funcarg" marked marker = getattr(obj, "_pytestfactory", None) if marker is not None: + if not isinstance(marker, FactoryMarker): + # magic globals with __getattr__ + # give us something thats wrong for that case + continue assert not name.startswith(self._argprefix) argname = name scope = marker.scope