python 3.11 fixes: traceback ^^^ helpers
This commit is contained in:
parent
316090eb5c
commit
737688eeb9
|
@ -1,4 +1,5 @@
|
||||||
import inspect
|
import inspect
|
||||||
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
@ -200,6 +201,7 @@ class TestDoctests:
|
||||||
"Traceback (most recent call last):",
|
"Traceback (most recent call last):",
|
||||||
' File "*/doctest.py", line *, in __run',
|
' File "*/doctest.py", line *, in __run',
|
||||||
" *",
|
" *",
|
||||||
|
*((" *^^^^*",) if sys.version_info >= (3, 11) else ()),
|
||||||
' File "<doctest test_doctest_unexpected_exception.txt[1]>", line 1, in <module>',
|
' File "<doctest test_doctest_unexpected_exception.txt[1]>", line 1, in <module>',
|
||||||
"ZeroDivisionError: division by zero",
|
"ZeroDivisionError: division by zero",
|
||||||
"*/test_doctest_unexpected_exception.txt:2: UnexpectedException",
|
"*/test_doctest_unexpected_exception.txt:2: UnexpectedException",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
@ -44,16 +45,32 @@ def test_wrap_session_notify_exception(ret_exc, pytester: Pytester) -> None:
|
||||||
assert result.ret == ExitCode.INTERNAL_ERROR
|
assert result.ret == ExitCode.INTERNAL_ERROR
|
||||||
assert result.stdout.lines[0] == "INTERNALERROR> Traceback (most recent call last):"
|
assert result.stdout.lines[0] == "INTERNALERROR> Traceback (most recent call last):"
|
||||||
|
|
||||||
|
end_lines = (
|
||||||
|
result.stdout.lines[-4:]
|
||||||
|
if sys.version_info >= (3, 11)
|
||||||
|
else result.stdout.lines[-3:]
|
||||||
|
)
|
||||||
|
|
||||||
if exc == SystemExit:
|
if exc == SystemExit:
|
||||||
assert result.stdout.lines[-3:] == [
|
assert end_lines == [
|
||||||
f'INTERNALERROR> File "{c1}", line 4, in pytest_sessionstart',
|
f'INTERNALERROR> File "{c1}", line 4, in pytest_sessionstart',
|
||||||
'INTERNALERROR> raise SystemExit("boom")',
|
'INTERNALERROR> raise SystemExit("boom")',
|
||||||
|
*(
|
||||||
|
("INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^",)
|
||||||
|
if sys.version_info >= (3, 11)
|
||||||
|
else ()
|
||||||
|
),
|
||||||
"INTERNALERROR> SystemExit: boom",
|
"INTERNALERROR> SystemExit: boom",
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
assert result.stdout.lines[-3:] == [
|
assert end_lines == [
|
||||||
f'INTERNALERROR> File "{c1}", line 4, in pytest_sessionstart',
|
f'INTERNALERROR> File "{c1}", line 4, in pytest_sessionstart',
|
||||||
'INTERNALERROR> raise ValueError("boom")',
|
'INTERNALERROR> raise ValueError("boom")',
|
||||||
|
*(
|
||||||
|
("INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^",)
|
||||||
|
if sys.version_info >= (3, 11)
|
||||||
|
else ()
|
||||||
|
),
|
||||||
"INTERNALERROR> ValueError: boom",
|
"INTERNALERROR> ValueError: boom",
|
||||||
]
|
]
|
||||||
if returncode is False:
|
if returncode is False:
|
||||||
|
|
Loading…
Reference in New Issue