Skip to content

Commit 2ab3aba

Browse files
committed
python 3.11 fixes: traceback ^^^ helpers
1 parent 9b3f2a3 commit 2ab3aba

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

testing/test_doctest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import inspect
2+
import sys
23
import textwrap
34
from pathlib import Path
45
from typing import Callable
@@ -200,6 +201,7 @@ def test_doctest_unexpected_exception(self, pytester: Pytester):
200201
"Traceback (most recent call last):",
201202
' File "*/doctest.py", line *, in __run',
202203
" *",
204+
*((" *^^^^*",) if sys.version_info >= (3, 11) else ()),
203205
' File "<doctest test_doctest_unexpected_exception.txt[1]>", line 1, in <module>',
204206
"ZeroDivisionError: division by zero",
205207
"*/test_doctest_unexpected_exception.txt:2: UnexpectedException",

testing/test_main.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import argparse
22
import os
33
import re
4+
import sys
45
from pathlib import Path
56
from typing import Optional
67

@@ -44,16 +45,32 @@ def pytest_internalerror(excrepr, excinfo):
4445
assert result.ret == ExitCode.INTERNAL_ERROR
4546
assert result.stdout.lines[0] == "INTERNALERROR> Traceback (most recent call last):"
4647

48+
end_lines = (
49+
result.stdout.lines[-4:]
50+
if sys.version_info >= (3, 11)
51+
else result.stdout.lines[-3:]
52+
)
53+
4754
if exc == SystemExit:
48-
assert result.stdout.lines[-3:] == [
55+
assert end_lines == [
4956
f'INTERNALERROR> File "{c1}", line 4, in pytest_sessionstart',
5057
'INTERNALERROR> raise SystemExit("boom")',
58+
*(
59+
("INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^",)
60+
if sys.version_info >= (3, 11)
61+
else ()
62+
),
5163
"INTERNALERROR> SystemExit: boom",
5264
]
5365
else:
54-
assert result.stdout.lines[-3:] == [
66+
assert end_lines == [
5567
f'INTERNALERROR> File "{c1}", line 4, in pytest_sessionstart',
5668
'INTERNALERROR> raise ValueError("boom")',
69+
*(
70+
("INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^",)
71+
if sys.version_info >= (3, 11)
72+
else ()
73+
),
5774
"INTERNALERROR> ValueError: boom",
5875
]
5976
if returncode is False:

0 commit comments

Comments
 (0)