diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index e4072ecdb..7abd3d53f 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -83,7 +83,7 @@ def iscoroutinefunction(func): def getlocation(function, curdir): fn = py.path.local(inspect.getfile(function)) - lineno = py.builtin._getcode(function).co_firstlineno + lineno = function.__code__.co_firstlineno if fn.relto(curdir): fn = fn.relto(curdir) return "%s:%d" % (fn, lineno + 1) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index bfae4cb61..495e6b9b3 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -354,8 +354,7 @@ class FixtureRequest(FuncargnamesCompatAttr): return self._pyfuncitem._testcase except AttributeError: function = getattr(self, "function", None) - if function is not None: - return py.builtin._getimself(function) + return getattr(function, "__self__", None) @scopeproperty() def module(self):