Skip to content

Commit 2753859

Browse files
authored
Merge pull request #7979 from nicoddemus/metafunc-ref
Add FunctionDefinition to the reference docs
2 parents a14a229 + 569c091 commit 2753859

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

doc/en/reference.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,13 @@ Function
840840
:members:
841841
:show-inheritance:
842842

843+
FunctionDefinition
844+
~~~~~~~~~~~~~~~~~~
845+
846+
.. autoclass:: _pytest.python.FunctionDefinition()
847+
:members:
848+
:show-inheritance:
849+
843850
Item
844851
~~~~
845852

src/_pytest/python.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,7 @@ def __init__(
960960
cls=None,
961961
module=None,
962962
) -> None:
963+
#: Access to the underlying :class:`_pytest.python.FunctionDefinition`.
963964
self.definition = definition
964965

965966
#: Access to the :class:`_pytest.config.Config` object for the test session.
@@ -1677,10 +1678,12 @@ def repr_failure( # type: ignore[override]
16771678

16781679

16791680
class FunctionDefinition(Function):
1680-
"""Internal hack until we get actual definition nodes instead of the
1681-
crappy metafunc hack."""
1681+
"""
1682+
This class is a step gap solution until we evolve to have actual function definition nodes
1683+
and manage to get rid of ``metafunc``.
1684+
"""
16821685

16831686
def runtest(self) -> None:
1684-
raise RuntimeError("function definitions are not supposed to be used")
1687+
raise RuntimeError("function definitions are not supposed to be run as tests")
16851688

16861689
setup = runtest

0 commit comments

Comments
 (0)