forked from pool/python-pytest-sphinx
Accepting request 1230261 from devel:languages:python:pytest
- Add patch support-python-313.patch: * Support Python 3.13 doctest changes. - Switch to autosetup macro. OBS-URL: https://build.opensuse.org/request/show/1230261 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pytest-sphinx?expand=0&rev=9
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Dec 12 04:44:11 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
|
||||
|
||||
- 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 <dmueller@suse.com>
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
104
support-python-313.patch
Normal file
104
support-python-313.patch
Normal file
@@ -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)"])
|
||||
Reference in New Issue
Block a user