##// END OF EJS Templates
Try to fix Pytest error on Python 3.13 (#14287)
M Bussonnier -
r28582:001109ab merge
parent child Browse files
Show More
@@ -65,7 +65,7 b' jobs:'
65 65 run: |
66 66 python -m pip install --only-binary ':all:' --upgrade pip setuptools wheel build
67 67 python -m pip install --only-binary ':all:' --no-binary curio --upgrade -e .[${{ matrix.deps }}]
68 python -m pip install --only-binary ':all:' --upgrade check-manifest pytest-cov pytest-json-report
68 python -m pip install --only-binary ':all:' --upgrade check-manifest pytest-cov pytest-json-report 'pytest<8'
69 69 - name: Install and update Python dependencies (dev?)
70 70 if: ${{ contains( matrix.python-version, 'dev' ) }}
71 71 run: |
@@ -84,7 +84,7 b' jobs:'
84 84 env:
85 85 COLUMNS: 120
86 86 run: |
87 pytest --color=yes -raXxs ${{ startsWith(matrix.python-version, 'pypy') && ' ' || '--cov --cov-report=xml' }} --json-report --json-report-file=./report-${{ matrix.python-version }}-${{runner.os}}.json
87 pytest --color=yes -raXxs ${{ startsWith(matrix.python-version, 'pypy') && ' ' || '--cov --cov-report=xml' }} --json-report --json-report-file=./report-${{ matrix.python-version }}-${{runner.os}}.json --maxfail=15
88 88 - uses: actions/upload-artifact@v3
89 89 with:
90 90 name: upload pytest timing reports as json
@@ -36,6 +36,7 b' Authors'
36 36
37 37 # Stdlib
38 38 import re
39 import sys
39 40 import unittest
40 41 from doctest import DocTestFinder, DocTestRunner, TestResults
41 42 from IPython.terminal.interactiveshell import InteractiveShell
@@ -49,7 +50,14 b' def count_failures(runner):'
49 50
50 51 Code modeled after the summarize() method in doctest.
51 52 """
52 return [TestResults(f, t) for f, t in runner._name2ft.values() if f > 0 ]
53 if sys.version_info < (3, 13):
54 return [TestResults(f, t) for f, t in runner._name2ft.values() if f > 0]
55 else:
56 return [
57 TestResults(failure, try_)
58 for failure, try_, skip in runner._stats.values()
59 if failure > 0
60 ]
53 61
54 62
55 63 class IPython2PythonConverter(object):
@@ -4,8 +4,8 b''
4 4 #
5 5 # Copyright (c) 2004-2021 Holger Krekel and others
6 6 """Discover and run ipdoctests in modules and test files."""
7 import builtins
8 7 import bdb
8 import builtins
9 9 import inspect
10 10 import os
11 11 import platform
@@ -15,25 +15,25 b' import types'
15 15 import warnings
16 16 from contextlib import contextmanager
17 17 from pathlib import Path
18 from typing import Any
19 from typing import Callable
20 from typing import Dict
21 from typing import Generator
22 from typing import Iterable
23 from typing import List
24 from typing import Optional
25 from typing import Pattern
26 from typing import Sequence
27 from typing import Tuple
28 from typing import Type
29 from typing import TYPE_CHECKING
30 from typing import Union
18 from typing import (
19 TYPE_CHECKING,
20 Any,
21 Callable,
22 Dict,
23 Generator,
24 Iterable,
25 List,
26 Optional,
27 Pattern,
28 Sequence,
29 Tuple,
30 Type,
31 Union,
32 )
31 33
32 34 import pytest
33 35 from _pytest import outcomes
34 from _pytest._code.code import ExceptionInfo
35 from _pytest._code.code import ReprFileLocation
36 from _pytest._code.code import TerminalRepr
36 from _pytest._code.code import ExceptionInfo, ReprFileLocation, TerminalRepr
37 37 from _pytest._io import TerminalWriter
38 38 from _pytest.compat import safe_getattr
39 39 from _pytest.config import Config
@@ -41,14 +41,15 b' from _pytest.config.argparsing import Parser'
41 41 from _pytest.fixtures import FixtureRequest
42 42 from _pytest.nodes import Collector
43 43 from _pytest.outcomes import OutcomeException
44 from _pytest.pathlib import fnmatch_ex
45 from _pytest.pathlib import import_path
44 from _pytest.pathlib import fnmatch_ex, import_path
46 45 from _pytest.python_api import approx
47 46 from _pytest.warning_types import PytestWarning
48 47
49 48 if TYPE_CHECKING:
50 49 import doctest
51 50
51 from .ipdoctest import IPDoctestOutputChecker
52
52 53 DOCTEST_REPORT_CHOICE_NONE = "none"
53 54 DOCTEST_REPORT_CHOICE_CDIFF = "cdiff"
54 55 DOCTEST_REPORT_CHOICE_NDIFF = "ndiff"
@@ -271,6 +272,8 b' def _get_runner('
271 272
272 273
273 274 class IPDoctestItem(pytest.Item):
275 _user_ns_orig: Dict[str, Any]
276
274 277 def __init__(
275 278 self,
276 279 name: str,
@@ -283,6 +286,7 b' class IPDoctestItem(pytest.Item):'
283 286 self.dtest = dtest
284 287 self.obj = None
285 288 self.fixture_request: Optional[FixtureRequest] = None
289 self._user_ns_orig = {}
286 290
287 291 @classmethod
288 292 def from_parent( # type: ignore
@@ -9,6 +9,7 b' import sys'
9 9 # Our own
10 10 from IPython.testing import decorators as dec
11 11 from IPython.testing.skipdoctest import skip_doctest
12 from IPython.utils.text import dedent
12 13
13 14 #-----------------------------------------------------------------------------
14 15 # Utilities
@@ -89,10 +90,11 b' def test_skip_dt_decorator():'
89 90 >>> 1+1
90 91 3
91 92 """
93
92 94 # Fetch the docstring from doctest_bad after decoration.
93 95 val = doctest_bad.__doc__
94
95 assert check == val, "doctest_bad docstrings don't match"
96
97 assert dedent(check) == dedent(val), "doctest_bad docstrings don't match"
96 98
97 99
98 100 # Doctest skipping should work for class methods too
@@ -52,7 +52,6 b' doc ='
52 52 docrepr
53 53 matplotlib
54 54 stack_data
55 pytest
56 55 typing_extensions
57 56 exceptiongroup
58 57 %(test)s
@@ -71,7 +70,7 b' qtconsole ='
71 70 qtconsole
72 71 terminal =
73 72 test =
74 pytest
73 pytest<8
75 74 pytest-asyncio<0.22
76 75 testpath
77 76 pickleshare
General Comments 0
You need to be logged in to leave comments. Login now