Export `FixtureDef`
FixtureDef is used in the `pytest_fixture_setup` hook so needs to be public. However since its current internals are quite dubious (and not all marked with `_` prefix) I've added an explicit note that only documented fields/methods are considered public. Refs #7469.
This commit is contained in:
parent
9d0ddb4625
commit
fb55615d5e
|
@ -0,0 +1 @@
|
|||
:class:`~pytest.FixtureDef` is now exported as ``pytest.FixtureDef`` for typing purposes.
|
|
@ -910,7 +910,7 @@ ExitCode
|
|||
FixtureDef
|
||||
~~~~~~~~~~
|
||||
|
||||
.. autoclass:: _pytest.fixtures.FixtureDef()
|
||||
.. autoclass:: pytest.FixtureDef()
|
||||
:members:
|
||||
:show-inheritance:
|
||||
|
||||
|
|
|
@ -216,6 +216,7 @@ def add_funcarg_pseudo_fixture_def(
|
|||
params=valuelist,
|
||||
unittest=False,
|
||||
ids=None,
|
||||
_ispytest=True,
|
||||
)
|
||||
arg2fixturedefs[argname] = [fixturedef]
|
||||
if name2pseudofixturedef is not None:
|
||||
|
@ -974,7 +975,11 @@ def _eval_scope_callable(
|
|||
|
||||
@final
|
||||
class FixtureDef(Generic[FixtureValue]):
|
||||
"""A container for a fixture definition."""
|
||||
"""A container for a fixture definition.
|
||||
|
||||
Note: At this time, only explicitly documented fields and methods are
|
||||
considered public stable API.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -988,7 +993,10 @@ class FixtureDef(Generic[FixtureValue]):
|
|||
ids: Optional[
|
||||
Union[Tuple[Optional[object], ...], Callable[[Any], Optional[object]]]
|
||||
] = None,
|
||||
*,
|
||||
_ispytest: bool = False,
|
||||
) -> None:
|
||||
check_ispytest(_ispytest)
|
||||
self._fixturemanager = fixturemanager
|
||||
# The "base" node ID for the fixture.
|
||||
#
|
||||
|
@ -1708,6 +1716,7 @@ class FixtureManager:
|
|||
params=marker.params,
|
||||
unittest=unittest,
|
||||
ids=marker.ids,
|
||||
_ispytest=True,
|
||||
)
|
||||
|
||||
faclist = self._arg2fixturedefs.setdefault(name, [])
|
||||
|
|
|
@ -20,6 +20,7 @@ from _pytest.config.argparsing import Parser
|
|||
from _pytest.debugging import pytestPDB as __pytestPDB
|
||||
from _pytest.doctest import DoctestItem
|
||||
from _pytest.fixtures import fixture
|
||||
from _pytest.fixtures import FixtureDef
|
||||
from _pytest.fixtures import FixtureLookupError
|
||||
from _pytest.fixtures import FixtureRequest
|
||||
from _pytest.fixtures import yield_fixture
|
||||
|
@ -102,6 +103,7 @@ __all__ = [
|
|||
"fail",
|
||||
"File",
|
||||
"fixture",
|
||||
"FixtureDef",
|
||||
"FixtureLookupError",
|
||||
"FixtureRequest",
|
||||
"freeze_includes",
|
||||
|
|
Loading…
Reference in New Issue