diff --git a/.pytest.toml b/.pytest.toml new file mode 100644 index 00000000000..801cb596947 --- /dev/null +++ b/.pytest.toml @@ -0,0 +1,35 @@ +# https://docs.pytest.org/en/stable/reference/customize.html + +[pytest] +minversion = "9.0" + +# https://docs.pytest.org/en/stable/reference/reference.html#command-line-flags +addopts = [ + # Show extra summary information for all non-passing tests + "-r a", + # https://docs.pytest.org/en/stable/explanation/pythonpath.html#import-modes + "--import-mode=importlib", + # https://pytest-cov.readthedocs.io/en/latest/config.html#reference + "--cov=check_peps", + "--cov=pep_sphinx_extensions", + "--cov-report=html", + "--cov-report=xml", +] + +# Fail if pytest.mark.parametrize() has no parameters +empty_parameter_set_mark = "fail_at_collect" + +filterwarnings = ["error"] + +testpaths = [ + "pep_sphinx_extensions", +] + +# https://docs.pytest.org/en/stable/reference/reference.html#confval-strict +strict_config = true +strict_markers = true +strict_parametrization_ids = true +strict_xfail = true + +# Various tests use Unicode in pytest.mark.parametrize(). +disable_test_id_escaping_and_forfeit_all_rights_to_community_support = true diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 10404cc0b3b..00000000000 --- a/pytest.ini +++ /dev/null @@ -1,16 +0,0 @@ -[pytest] -# https://docs.pytest.org/en/7.3.x/reference/reference.html#command-line-flags -addopts = - -r a - --strict-config - --strict-markers - --import-mode=importlib - --cov check_peps --cov pep_sphinx_extensions - --cov-report html --cov-report xml -empty_parameter_set_mark = fail_at_collect -filterwarnings = - error -minversion = 6.0 -testpaths = pep_sphinx_extensions -xfail_strict = True -disable_test_id_escaping_and_forfeit_all_rights_to_community_support = True diff --git a/requirements.txt b/requirements.txt index 07d631cee6f..945d29d4d46 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ docutils >= 0.19.0 sphinx-notfound-page >= 1.0.2 # For tests -pytest +pytest>=9 pytest-cov # For python-releases.toml diff --git a/tox.ini b/tox.ini index c54968afebe..5427b2511e2 100644 --- a/tox.ini +++ b/tox.ini @@ -12,3 +12,12 @@ pass_env = FORCE_COLOR commands = python -bb -X dev -W error -m pytest {posargs} + +[coverage:run] +omit = + */__main__.py # Ignore all __main__.py files + peps/* # Ignore all files in the PEPs folder + +[coverage:report] +exclude_also = + if __name__ == .__main__.: