diff --git a/python-pytest-sphinx.changes b/python-pytest-sphinx.changes index 29fe80d..84f8656 100644 --- a/python-pytest-sphinx.changes +++ b/python-pytest-sphinx.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu Dec 12 04:44:11 UTC 2024 - Steve Kowalik + +- Add patch support-python-313.patch: + * Support Python 3.13 doctest changes. +- Switch to autosetup macro. + ------------------------------------------------------------------- Wed Aug 14 14:54:31 UTC 2024 - Dirk Müller diff --git a/python-pytest-sphinx.spec b/python-pytest-sphinx.spec index 350b199..85064ef 100644 --- a/python-pytest-sphinx.spec +++ b/python-pytest-sphinx.spec @@ -24,6 +24,7 @@ Summary: Doctest plugin for pytest with support for Sphinx-specific docte License: BSD-3-Clause URL: https://github.com/thisch/pytest-sphinx Source: https://github.com/thisch/pytest-sphinx/archive/v%{version}.tar.gz#/pytest-sphinx-%{version}.tar.gz +Patch0: support-python-313.patch BuildRequires: %{python_module base >= 3.8} BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} @@ -42,7 +43,7 @@ BuildRequires: %{python_module pytest >= 8.1.1} Doctest plugin for pytest with support for Sphinx-specific doctest-directives. %prep -%setup -q -n pytest-sphinx-%{version} +%autosetup -p1 -n pytest-sphinx-%{version} %build %pyproject_wheel diff --git a/support-python-313.patch b/support-python-313.patch new file mode 100644 index 0000000..d6668d5 --- /dev/null +++ b/support-python-313.patch @@ -0,0 +1,104 @@ +Index: pytest-sphinx-0.6.3/src/pytest_sphinx.py +=================================================================== +--- pytest-sphinx-0.6.3.orig/src/pytest_sphinx.py ++++ pytest-sphinx-0.6.3/src/pytest_sphinx.py +@@ -495,7 +495,12 @@ class SphinxDocTestRunner(doctest.DebugR + self.optionflags = original_optionflags + + # Record and return the number of failures and tries. +- self._DocTestRunner__record_outcome(test, failures, tries) # type:ignore ++ # And for Python 3.13 and above, also pass the number of skips, which ++ # is always zero if we got here. ++ if sys.version_info[:2] >= (3, 13): ++ self._DocTestRunner__record_outcome(test, failures, tries, 0) # type:ignore ++ else: ++ self._DocTestRunner__record_outcome(test, failures, tries) # type:ignore + return doctest.TestResults(failures, tries) + + +Index: pytest-sphinx-0.6.3/tests/test_sphinx_doctest.py +=================================================================== +--- pytest-sphinx-0.6.3.orig/tests/test_sphinx_doctest.py ++++ pytest-sphinx-0.6.3/tests/test_sphinx_doctest.py +@@ -3,6 +3,7 @@ + import logging + import os + import subprocess ++import sys + import textwrap + from pathlib import Path + from typing import Iterator +@@ -14,6 +15,10 @@ from _pytest.legacypath import Testdir + + logger = logging.getLogger(__name__) + ++testoutput = "1 items passed all tests" ++if sys.version_info[:2] >= (3, 13): ++ testoutput = "Testing of doctests in the sources finished" ++ + + class SphinxDoctestRunner: + def __init__(self, tmp_path: Path) -> None: +@@ -106,7 +111,7 @@ def test_simple_doctest_success(sphinx_t + 6 + """ + ) +- assert "1 items passed all tests" in output ++ assert testoutput in output + + + class TestDirectives: +@@ -124,7 +129,7 @@ class TestDirectives: + """ + + sphinx_output = sphinx_tester(code) +- assert "1 items passed all tests" in sphinx_output ++ assert testoutput in sphinx_output + + plugin_result = testdir.runpytest("--doctest-glob=index.rst").stdout + plugin_result.fnmatch_lines(["*=== 1 passed in *"]) +@@ -140,7 +145,7 @@ class TestDirectives: + """ + + sphinx_output = sphinx_tester(code) +- assert "1 items passed all tests" in sphinx_output ++ assert testoutput in sphinx_output + + plugin_result = testdir.runpytest("--doctest-glob=index.rst").stdout + plugin_result.fnmatch_lines(["*=== 1 passed in *"]) +@@ -171,7 +176,7 @@ class TestDirectives: + """ + + sphinx_output = sphinx_tester(code) +- assert "1 items passed all tests" in sphinx_output ++ assert testoutput in sphinx_output + + plugin_result = testdir.runpytest("--doctest-glob=index.rst").stdout + plugin_result.fnmatch_lines(["*=== 1 passed in *"]) +@@ -204,7 +209,7 @@ class TestDirectives: + assert "1 failure in tests" in sphinx_output + plugin_output.fnmatch_lines(["*=== 1 failed in *"]) + else: +- assert "1 items passed all tests" in sphinx_output ++ assert testoutput in sphinx_output + plugin_output.fnmatch_lines(["*=== 1 passed in *"]) + + @pytest.mark.parametrize( +@@ -235,7 +240,7 @@ class TestDirectives: + assert "1 failure in tests" in sphinx_output + plugin_output.fnmatch_lines(["*=== 1 failed in *"]) + else: +- assert "1 items passed all tests" in sphinx_output ++ assert testoutput in sphinx_output + plugin_output.fnmatch_lines(["*=== 1 passed in *"]) + + @pytest.mark.parametrize("wrong_output_assertion", [True, False]) +@@ -279,7 +284,7 @@ class TestDirectives: + assert "1 failure in tests" in sphinx_output + plugin_output.fnmatch_lines(["*=== 1 failed in *"]) + else: +- assert "1 items passed all tests" in sphinx_output ++ assert testoutput in sphinx_output + plugin_output.fnmatch_lines(["*=== 1 passed in *"]) + + @pytest.mark.parametrize("testcode", ["raise RuntimeError", "pass", "print(1234)"])