MCPcopy
hub / github.com/pytest-dev/pytest / __init__

Method __init__

src/_pytest/python.py:1606–1655  ·  view source on GitHub ↗
(
        self,
        name: str,
        parent,
        config: Config | None = None,
        callspec: CallSpec2 | None = None,
        callobj=NOTSET,
        keywords: Mapping[str, Any] | None = None,
        session: Session | None = None,
        fixtureinfo: FuncFixtureInfo | None = None,
        originalname: str | None = None,
    )

Source from the content-addressed store, hash-verified

1604 _ALLOW_MARKERS = False
1605
1606 def __init__(
1607 self,
1608 name: str,
1609 parent,
1610 config: Config | None = None,
1611 callspec: CallSpec2 | None = None,
1612 callobj=NOTSET,
1613 keywords: Mapping[str, Any] | None = None,
1614 session: Session | None = None,
1615 fixtureinfo: FuncFixtureInfo | None = None,
1616 originalname: str | None = None,
1617 ) -> None:
1618 super().__init__(name, parent, config=config, session=session)
1619
1620 if callobj is not NOTSET:
1621 self._obj = callobj
1622 self._instance = getattr(callobj, "__self__", None)
1623
1624 #: Original function name, without any decorations (for example
1625 #: parametrization adds a ``"[...]"`` suffix to function names), used to access
1626 #: the underlying function object from ``parent`` (in case ``callobj`` is not given
1627 #: explicitly).
1628 #:
1629 #: .. versionadded:: 3.0
1630 self.originalname = originalname or name
1631
1632 # Note: when FunctionDefinition is introduced, we should change ``originalname``
1633 # to a readonly property that returns FunctionDefinition.name.
1634
1635 self.own_markers.extend(get_unpacked_marks(self.obj))
1636 if callspec:
1637 self.callspec = callspec
1638 self.own_markers.extend(callspec.marks)
1639
1640 # todo: this is a hell of a hack
1641 # https://github.com/pytest-dev/pytest/issues/4569
1642 # Note: the order of the updates is important here; indicates what
1643 # takes priority (ctor argument over function attributes over markers).
1644 # Take own_markers only; NodeKeywords handles parent traversal on its own.
1645 self.keywords.update((mark.name, mark) for mark in self.own_markers)
1646 self.keywords.update(self.obj.__dict__)
1647 if keywords:
1648 self.keywords.update(keywords)
1649
1650 if fixtureinfo is None:
1651 fm = self.session._fixturemanager
1652 fixtureinfo = fm.getfixtureinfo(self, self.obj, self.cls)
1653 self._fixtureinfo: FuncFixtureInfo = fixtureinfo
1654 self.fixturenames = fixtureinfo.names_closure
1655 self._initrequest()
1656
1657 # todo: determine sound type limitations
1658 @classmethod

Callers

nothing calls this directly

Calls 5

_initrequestMethod · 0.95
get_unpacked_marksFunction · 0.90
updateMethod · 0.80
getfixtureinfoMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected