Coverage for src/pytest_samples/plugin/__init__.py: 100%
12 statements
« prev ^ index » next coverage.py v7.4.2, created at 2024-02-20 19:47 +0000
« prev ^ index » next coverage.py v7.4.2, created at 2024-02-20 19:47 +0000
1"""This module contains the entrypoint and the actual plugin
2implementation.
3"""
5__all__ = [
6 "SamplesBrokerBootstrap", "CmdFlags",
7 "SamplesBrokerBase", "NoStateSamplesBroker",
8 "ImmediateStatefulSamplesBroker", "LazyStatefulSamplesBroker",
9 "TestResultStateNotImplementedWarning",
10 "pytest_load_initial_conftests"
11]
13import sys as _sys
15from pytest import Config as _Config
17from ._bootstrap import SamplesBrokerBootstrap, CmdFlags
18from ._broker_base import SamplesBrokerBase
19from ._broker_nostate import NoStateSamplesBroker
20from ._broker_stateful import ImmediateStatefulSamplesBroker, \
21 LazyStatefulSamplesBroker, TestResultStateNotImplementedWarning
23from . import _meta
26_this_module = _sys.modules[__name__]
27"""The object representing this module "plugin" containing the initial
28version of the plugin.
29"""
32# Registering the plugin here makes it possible to let the ini config
33# file decide which broker to load. This may be useful for future
34# extensions.
35def pytest_load_initial_conftests(early_config: _Config) -> None:
36 """Function called as part of pytest bootstrapping. Internally used
37 to load conftests. Here used to install the plugin.
39 Args:
40 early_config (Config): The config.
41 args (List[str]): The command line arguments.
42 parser (Parser): The parser.
44 Raises:
45 RuntimeError: If the plugin could not be registered.
46 """
47 _meta.swap_plugin(
48 early_config.pluginmanager, _this_module, SamplesBrokerBootstrap()
49 )