Merge pull request #7979 from nicoddemus/metafunc-ref

Add FunctionDefinition to the reference docs
This commit is contained in:
Bruno Oliveira 2020-10-31 10:00:48 -03:00 committed by GitHub
commit 2753859ff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -840,6 +840,13 @@ Function
:members:
:show-inheritance:
FunctionDefinition
~~~~~~~~~~~~~~~~~~
.. autoclass:: _pytest.python.FunctionDefinition()
:members:
:show-inheritance:
Item
~~~~

View File

@ -960,6 +960,7 @@ class Metafunc:
cls=None,
module=None,
) -> None:
#: Access to the underlying :class:`_pytest.python.FunctionDefinition`.
self.definition = definition
#: Access to the :class:`_pytest.config.Config` object for the test session.
@ -1677,10 +1678,12 @@ class Function(PyobjMixin, nodes.Item):
class FunctionDefinition(Function):
"""Internal hack until we get actual definition nodes instead of the
crappy metafunc hack."""
"""
This class is a step gap solution until we evolve to have actual function definition nodes
and manage to get rid of ``metafunc``.
"""
def runtest(self) -> None:
raise RuntimeError("function definitions are not supposed to be used")
raise RuntimeError("function definitions are not supposed to be run as tests")
setup = runtest