Add ability to exclude files matching glob patterns in conftest.py

This adds the `collect_ignore_glob` option for `conftest.py` to allow
Unix-style wildcards for excluding files.
This commit is contained in:
Christian Fetzer
2019-02-06 10:50:46 +01:00
parent fc5d4654e5
commit 2dc2a19db5
4 changed files with 39 additions and 1 deletions

View File

@@ -269,3 +269,17 @@ file will be left out:
collected 0 items
======================= no tests ran in 0.12 seconds =======================
It's also possible to ignore files based on Unix shell-style wildcards by adding
patterns to ``collect_ignore_glob``.
The following example ``conftest.py`` ignores the file ``setup.py`` and in
addition all files that end with ``*_py2.py`` when executed with a Python 3
interpreter::
# content of conftest.py
import sys
collect_ignore = ["setup.py"]
if sys.version_info[0] > 2:
collect_ignore_glob = ["*_py2.py"]