From f4564668a6451f35b987a34d206208f997d24934 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 24 Nov 2025 18:06:50 +0000 Subject: [PATCH 1/2] Improve tests and coverage configuration --- .pytest.toml | 35 +++++++++++++++++++++++++++++++++++ pytest.ini | 16 ---------------- requirements.txt | 2 +- tox.ini | 11 +++++++++++ 4 files changed, 47 insertions(+), 17 deletions(-) create mode 100644 .pytest.toml delete mode 100644 pytest.ini 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..9709610834e 100644 --- a/tox.ini +++ b/tox.ini @@ -12,3 +12,14 @@ pass_env = FORCE_COLOR commands = python -bb -X dev -W error -m pytest {posargs} + +[coverage:run] +omit = + # Ignore all __main__.py files + */__main__.py + # Ignore all files in the PEPs folder + peps/* + +[coverage:report] +exclude_also = + if __name__ == .__main__.: From f77f1541924e1f338e104129e30f628dcf6828b6 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 24 Nov 2025 18:30:06 +0000 Subject: [PATCH 2/2] Fix tox.ini comments --- tox.ini | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index 9709610834e..5427b2511e2 100644 --- a/tox.ini +++ b/tox.ini @@ -15,10 +15,8 @@ commands = [coverage:run] omit = - # Ignore all __main__.py files - */__main__.py - # Ignore all files in the PEPs folder - peps/* + */__main__.py # Ignore all __main__.py files + peps/* # Ignore all files in the PEPs folder [coverage:report] exclude_also =