MCPcopy Create free account
hub / github.com/pytest-dev/pytest / instance

Method instance

src/_pytest/python.py:282–289  ·  view source on GitHub ↗

Python instance object the function is bound to. Returns None if not a test method, e.g. for a standalone test function, a staticmethod, a class or a module.

(self)

Source from the content-addressed store, hash-verified

280
281 @property
282 def instance(self):
283 """Python instance object the function is bound to.
284
285 Returns None if not a test method, e.g. for a standalone test function,
286 a staticmethod, a class or a module.
287 """
288 node = self.getparent(Function)
289 return getattr(node.obj, "__self__", None) if node is not None else None
290
291 @property
292 def obj(self):

Callers

nothing calls this directly

Calls 1

getparentMethod · 0.80

Tested by

no test coverage detected