pytest
======

.. py:module:: pytest


Attributes
----------

.. autoapisummary::

   pytest.test_errors
   pytest.IN_CI_MODE
   pytest.DEFAULT_EXCLUDE_LIST


Functions
---------

.. autoapisummary::

   pytest.require_tool
   pytest.pytest_addoption
   pytest.env_protect
   pytest.pytest_configure
   pytest.pytest_sessionfinish
   pytest.fix_coverage_paths
   pytest.pytest_runtest_makereport


Module Contents
---------------

.. py:data:: test_errors
   :value: False


.. py:data:: IN_CI_MODE

.. py:data:: DEFAULT_EXCLUDE_LIST
   :value: ('all: no cover', 'if TYPE_CHECKING:', '@abstractmethod', '# os-specific', 'defensive code',...


.. py:function:: 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.

   :param toolname: name of a tool, e.g. git


.. py:function:: pytest_addoption(parser: Parser, pluginmanager: PytestPluginManager) -> None

.. py:function:: env_protect(request: FixtureRequest) -> None

   Protection against environment change.

   The fixture is enabled for all tests and does the following:

   * store/restore env between tests
   * create a temporary directory and do a cd to it before each
     test. The directory is automatically removed when test ends


.. py:function:: pytest_configure(config: Config) -> None

.. py:function:: pytest_sessionfinish(session: Session, exitstatus: int) -> None

   Manage the exit code depending on if errors were detected or not.


.. py:function:: fix_coverage_paths(origin_dir: str, new_dir: str, cov_db: str) -> None

   Fix coverage paths.

   :param origin_dir: path to the package directory, e.g.
       .tox/py311-cov-xdist/lib/python3.11/site-packages/e3
   :param new_dir: path to the dir that should be visible instead of origin_dir
       e.g. src/
   :param cov_db: path to the .coverage database


.. py:function:: 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.


