pytest
¶
Module Contents¶
Functions¶
|
Require a specific tool to run the test. |
|
|
|
Protection against environment change. |
|
|
|
Manage the exit code depending on if errors were detected or not. |
|
Fix coverage paths. |
|
Generate results file. |
Attributes¶
- pytest.test_errors = False¶
- pytest.IN_CI_MODE¶
- pytest.DEFAULT_EXCLUDE_LIST = ('all: no cover', 'if TYPE_CHECKING:', '@abstractmethod', '# os-specific', 'defensive code',...¶
- pytest.require_tool(toolname: str) Callable ¶
Require a specific tool to run the test.
When in “CI” mode, a missing tool generates an error. In other modes the test is just skipped.
- Parameters:
toolname – name of a tool, e.g. git
- pytest.pytest_addoption(parser: Parser, pluginmanager: PytestPluginManager) None ¶
- pytest.env_protect(request: FixtureRequest) None ¶
Protection against environment change.
The fixture is enabled for all tests and does the following:
store/restore env between each tests
create a temporary directory and do a cd to it before each test. The directory is automatically removed when test ends
- pytest.pytest_sessionfinish(session: Session, exitstatus: int) None ¶
Manage the exit code depending on if errors were detected or not.
- pytest.fix_coverage_paths(origin_dir: str, new_dir: str, cov_db: str) None ¶
Fix coverage paths.
- Parameters:
origin_dir – path to the package directory, e.g. .tox/py311-cov-xdist/lib/python3.11/site-packages/e3
new_dir – path to the dir that should be visible instead of origin_dir e.g. src/
cov_db – path to the .coverage data base
- pytest.pytest_runtest_makereport(item: Item, call: CallInfo[None]) None ¶
Generate results file.
When the variable results_dir is set to an existing directory, the testsuite will generate results file in “anod” format.