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

Method __init__

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

Source from the content-addressed store, hash-verified

1624 _ALLOW_MARKERS = False
1625
1626 def __init__(
1627 self,
1628 name: str,
1629 parent,
1630 config: Optional[Config] = None,
1631 callspec: Optional[CallSpec2] = None,
1632 callobj=NOTSET,
1633 keywords=None,
1634 session: Optional[Session] = None,
1635 fixtureinfo: Optional[FuncFixtureInfo] = None,
1636 originalname: Optional[str] = None,
1637 ) -> None:
1638 super().__init__(name, parent, config=config, session=session)
1639
1640 if callobj is not NOTSET:
1641 self.obj = callobj
1642
1643 #: Original function name, without any decorations (for example
1644 #: parametrization adds a ``"[...]"`` suffix to function names), used to access
1645 #: the underlying function object from ``parent`` (in case ``callobj`` is not given
1646 #: explicitly).
1647 #:
1648 #: .. versionadded:: 3.0
1649 self.originalname = originalname or name
1650
1651 # Note: when FunctionDefinition is introduced, we should change ``originalname``
1652 # to a readonly property that returns FunctionDefinition.name.
1653
1654 self.keywords.update(self.obj.__dict__)
1655 self.own_markers.extend(get_unpacked_marks(self.obj))
1656 if callspec:
1657 self.callspec = callspec
1658 # this is total hostile and a mess
1659 # keywords are broken by design by now
1660 # this will be redeemed later
1661 for mark in callspec.marks:
1662 # feel free to cry, this was broken for years before
1663 # and keywords can't fix it per design
1664 self.keywords[mark.name] = mark
1665 self.own_markers.extend(normalize_mark_list(callspec.marks))
1666 if keywords:
1667 self.keywords.update(keywords)
1668
1669 # todo: this is a hell of a hack
1670 # https://github.com/pytest-dev/pytest/issues/4569
1671
1672 self.keywords.update(
1673 {
1674 mark.name: True
1675 for mark in self.iter_markers()
1676 if mark.name not in self.keywords
1677 }
1678 )
1679
1680 if fixtureinfo is None:
1681 fixtureinfo = self.session._fixturemanager.getfixtureinfo(
1682 self, self.obj, self.cls, funcargs=True
1683 )

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected