2020-12-20 04:19:51 +08:00
The types of objects used in pytest's API are now exported so they may be used in type annotations.
The newly-exported types are:
2021-05-24 16:45:07 +08:00
- `` pytest.Config `` for :class: `Config <pytest.Config>` .
2020-12-20 04:19:51 +08:00
- `` pytest.Mark `` for :class: `marks <pytest.Mark>` .
2020-12-20 21:11:01 +08:00
- `` pytest.MarkDecorator `` for :class: `mark decorators <pytest.MarkDecorator>` .
2020-12-20 21:36:24 +08:00
- `` pytest.MarkGenerator `` for the :class: `pytest.mark <pytest.MarkGenerator>` singleton.
2021-03-13 17:10:34 +08:00
- `` pytest.Metafunc `` for the :class: `metafunc <pytest.MarkGenerator>` argument to the :func: `pytest_generate_tests <pytest.hookspec.pytest_generate_tests>` hook.
- `` pytest.CallInfo `` for the :class: `CallInfo <pytest.CallInfo>` type passed to various hooks.
2021-05-24 17:16:16 +08:00
- `` pytest.PytestPluginManager `` for :class: `PytestPluginManager <pytest.PytestPluginManager>` .
2021-03-13 17:10:34 +08:00
- `` pytest.ExceptionInfo `` for the :class: `ExceptionInfo <pytest.ExceptionInfo>` type returned from :func: `pytest.raises` and passed to various hooks.
2021-05-24 04:45:49 +08:00
- `` pytest.Parser `` for the :class: `Parser <pytest.Parser>` type passed to the :func: `pytest_addoption <pytest.hookspec.pytest_addoption>` hook.
- `` pytest.OptionGroup `` for the :class: `OptionGroup <pytest.OptionGroup>` type returned from the :func: `parser.addgroup <pytest.Parser.getgroup>` method.
2021-10-22 16:34:36 +08:00
- `` pytest.HookRecorder `` for the :class: `HookRecorder <pytest.HookRecorder>` type returned from :class: `~pytest.Pytester` .
- `` pytest.RecordedHookCall `` for the :class: `RecordedHookCall <pytest.HookRecorder>` type returned from :class: `~pytest.HookRecorder` .
- `` pytest.RunResult `` for the :class: `RunResult <pytest.RunResult>` type returned from :class: `~pytest.Pytester` .
- `` pytest.LineMatcher `` for the :class: `LineMatcher <pytest.RunResult>` type used in :class: `~pytest.RunResult` and others.
2020-12-20 04:19:51 +08:00
2021-10-22 16:34:36 +08:00
Constructing most of them directly is not supported; they are only meant for use in type annotations.
2021-07-03 18:20:12 +08:00
Doing so will emit a deprecation warning, and may become a hard-error in pytest 8.0.
2020-12-20 04:19:51 +08:00
Subclassing them is also not supported. This is not currently enforced at runtime, but is detected by type-checkers such as mypy.