Global Variables ​
pytest treats some global variables in a special manner when defined in a test module or conftest.py files.
collect_ignore ​
Tutorial: Customizing test collection
Can be declared in conftest.py files to exclude test directories or modules. Needs to be a list of paths (str, pathlib.Path or any os.PathLike).
collect_ignore = ["setup.py"]collect_ignore = ["setup.py"]collect_ignore_glob ​
Tutorial: Customizing test collection
Can be declared in conftest.py files to exclude test directories or modules with Unix shell-style wildcards. Needs to be list[str] where str can contain glob patterns.
collect_ignore_glob = ["*_ignore.py"]collect_ignore_glob = ["*_ignore.py"]pytest_plugins ​
Tutorial: Requiring/Loading plugins in a test module or conftest file
Can be declared at the global level in test modules and conftest.py files to register additional - plugins. Can be either a str or Sequence[str].
pytest_plugins = "myapp.testsupport.myplugin"pytest_plugins = "myapp.testsupport.myplugin"pytest_plugins = ("myapp.testsupport.tools", "myapp.testsupport.regression")pytest_plugins = ("myapp.testsupport.tools", "myapp.testsupport.regression")pytestmark ​
Tutorial: Marking whole classes or modules
Can be declared at the global level in test modules to apply one or more marks to all test - functions and methods. Can be either a single mark or a list of marks (applied in left-to-right - order).
import pytest
pytestmark = pytest.mark.webtestimport pytest
pytestmark = pytest.mark.webtestimport pytest
pytestmark = [pytest.mark.integration, pytest.mark.slow]import pytest
pytestmark = [pytest.mark.integration, pytest.mark.slow]