Skip to content

Commit 0c8d612

Browse files
authored
Merge pull request #192 from musicinmybrain/python3.13
Adapt to changes to doctest statistic tracking internals in Python 3.13
2 parents 5152ade + 16d4da9 commit 0c8d612

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

.github/workflows/pip.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
matrix:
17-
python-version: ["3.11", "3.12"]
17+
python-version: ['3.11', '3.12', '3.13']
1818
numpy: ['"numpy<2.0"', "numpy"]
1919
os: [ubuntu-latest]
2020
pytest: [pytest]

scipy_doctest/impl.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import doctest
55
from doctest import NORMALIZE_WHITESPACE, ELLIPSIS, IGNORE_EXCEPTION_DETAIL
66
from itertools import zip_longest
7+
from sys import version_info
78

89
import numpy as np
910

@@ -514,11 +515,15 @@ def report_failure(self, out, test, example, got):
514515
def get_history(self):
515516
"""Return a dict with names of items which were run.
516517
517-
Actually the dict is `{name : (f, t)}`, where `name` is the name of
518-
an object, and the value is a tuple of the numbers of examples which
519-
failed and which were tried.
518+
Actually the dict is `{name : (failures, tries, skips)}` (before Python
519+
3.13, just `{name : (failures, tries, skips)}`) where `name` is the
520+
name of an object, and the value is a tuple of the numbers of examples
521+
which failed, were tried, and were skipped, respectively.
520522
"""
521-
return self._name2ft
523+
if version_info >= (3, 13):
524+
return self._stats
525+
else:
526+
return self._name2ft
522527

523528

524529
class DebugDTRunner(DTRunner):

scipy_doctest/tests/test_skipmarkers.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import doctest
2+
from sys import version_info
23

34
try:
45
import matplotlib.pyplot as plt # noqa
@@ -57,7 +58,8 @@ def test_invalid_python_plus_skip(self):
5758
lineno=0)
5859
runner = DebugDTRunner()
5960
runner.run(test)
60-
assert runner.get_history() == {'none : +SKIP': (0, 0)}
61+
stats = (0, 1, 1) if version_info >= (3, 13) else (0, 0)
62+
assert runner.get_history() == {'none : +SKIP': stats}
6163

6264
def test_invalid_python_pseudocode(self):
6365
# Marking a test as pseudocode is equivalent to a +SKIP:
@@ -74,7 +76,8 @@ def test_invalid_python_pseudocode(self):
7476
lineno=0)
7577
runner = DebugDTRunner()
7678
runner.run(test)
77-
assert runner.get_history() == {'none : pseudocode': (0, 0)}
79+
stats = (0, 1, 1) if version_info >= (3, 13) else (0, 0)
80+
assert runner.get_history() == {'none : pseudocode': stats}
7881

7982

8083
class TestPseudocodeMarkers:
@@ -125,7 +128,8 @@ def test_bogus_output(self):
125128
runner.run(test)
126129

127130
# one example tried, of which zero failed
128-
assert runner.get_history() == {'stopwords_bogus_output': (0, 1)}
131+
stats = (0, 1, 0) if version_info >= (3, 13) else (0, 1)
132+
assert runner.get_history() == {'stopwords_bogus_output': stats}
129133

130134

131135
class TestMayVary:
@@ -148,7 +152,8 @@ def test_may_vary(self):
148152
runner.run(test)
149153

150154
# one example tried, of which zero failed
151-
assert runner.get_history() == {'may_vary_markers': (0, 1)}
155+
stats = (0, 1, 0) if version_info >= (3, 13) else (0, 1)
156+
assert runner.get_history() == {'may_vary_markers': stats}
152157

153158
def test_may_vary_source(self):
154159
# The marker needs to be added to the example output, not source.
@@ -164,7 +169,8 @@ def test_may_vary_source(self):
164169
runner.run(test)
165170

166171
# one example tried, of which zero failed
167-
assert runner.get_history() == {'may_vary_source': (0, 1)}
172+
stats = (0, 1, 0) if version_info >= (3, 13) else (0, 1)
173+
assert runner.get_history() == {'may_vary_source': stats}
168174

169175
def test_may_vary_syntax_error(self):
170176
# `# may vary` markers do not mask syntax errors, unlike `# doctest: +SKIP`

0 commit comments

Comments
 (0)