diff options
author | Ran Benita <ran@unusedvar.com> | 2020-12-20 15:36:24 +0200 |
---|---|---|
committer | Ran Benita <ran@unusedvar.com> | 2020-12-20 15:59:20 +0200 |
commit | 6aa4d1c7ab968aecf44ad89e568a4515bd7e5343 (patch) | |
tree | 267cac94cd4d8200751ac7e4987393da0c1d3b2a /src/_pytest | |
parent | 69c302479e3f76450f29e7d2de24254d5eda6492 (diff) | |
download | pytest-6aa4d1c7ab968aecf44ad89e568a4515bd7e5343.tar.gz |
mark: export pytest.MarkGenerator for typing purposes
The type cannot be constructed directly, but is exported for use in type
annotations, since it is reachable through existing public API.
Diffstat (limited to 'src/_pytest')
-rw-r--r-- | src/_pytest/mark/structures.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 8bce33e68..ae6920735 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -488,9 +488,6 @@ class MarkGenerator: applies a 'slowtest' :class:`Mark` on ``test_function``. """ - _config: Optional[Config] = None - _markers: Set[str] = set() - # See TYPE_CHECKING above. if TYPE_CHECKING: skip: _SkipMarkDecorator @@ -500,7 +497,13 @@ class MarkGenerator: usefixtures: _UsefixturesMarkDecorator filterwarnings: _FilterwarningsMarkDecorator + def __init__(self, *, _ispytest: bool = False) -> None: + check_ispytest(_ispytest) + self._config: Optional[Config] = None + self._markers: Set[str] = set() + def __getattr__(self, name: str) -> MarkDecorator: + """Generate a new :class:`MarkDecorator` with the given name.""" if name[0] == "_": raise AttributeError("Marker name must NOT start with underscore") @@ -541,7 +544,7 @@ class MarkGenerator: return MarkDecorator(Mark(name, (), {}, _ispytest=True), _ispytest=True) -MARK_GEN = MarkGenerator() +MARK_GEN = MarkGenerator(_ispytest=True) @final |