[8.2.x] Add Python 3.13 (beta) support
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# mypy: allow-untyped-defs
|
||||
from __future__ import annotations
|
||||
|
||||
import fnmatch
|
||||
import importlib
|
||||
import io
|
||||
import operator
|
||||
@@ -237,7 +238,7 @@ class TestTraceback_f_g_h:
|
||||
n += 1
|
||||
f(n)
|
||||
|
||||
excinfo = pytest.raises(RuntimeError, f, 8)
|
||||
excinfo = pytest.raises(RecursionError, f, 8)
|
||||
traceback = excinfo.traceback
|
||||
recindex = traceback.recursionindex()
|
||||
assert recindex == 3
|
||||
@@ -373,7 +374,10 @@ def test_excinfo_no_sourcecode():
|
||||
except ValueError:
|
||||
excinfo = _pytest._code.ExceptionInfo.from_current()
|
||||
s = str(excinfo.traceback[-1])
|
||||
assert s == " File '<string>':1 in <module>\n ???\n"
|
||||
# TODO: Since Python 3.13b1 under pytest-xdist, the * is `import
|
||||
# sys;exec(eval(sys.stdin.readline()))` (execnet bootstrap code)
|
||||
# instead of `???` like before. Is this OK?
|
||||
fnmatch.fnmatch(s, " File '<string>':1 in <module>\n *\n")
|
||||
|
||||
|
||||
def test_excinfo_no_python_sourcecode(tmp_path: Path) -> None:
|
||||
|
||||
@@ -370,7 +370,11 @@ def test_getfslineno() -> None:
|
||||
pass
|
||||
|
||||
B.__name__ = B.__qualname__ = "B2"
|
||||
assert getfslineno(B)[1] == -1
|
||||
# Since Python 3.13 this started working.
|
||||
if sys.version_info >= (3, 13):
|
||||
assert getfslineno(B)[1] != -1
|
||||
else:
|
||||
assert getfslineno(B)[1] == -1
|
||||
|
||||
|
||||
def test_code_of_object_instance_with_call() -> None:
|
||||
|
||||
@@ -194,7 +194,7 @@ class TestNewAPI:
|
||||
assert pytester.path.joinpath("custom_cache_dir").is_dir()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("env", ((), ("TOX_ENV_DIR", "/tox_env_dir")))
|
||||
@pytest.mark.parametrize("env", ((), ("TOX_ENV_DIR", "mydir/tox-env")))
|
||||
def test_cache_reportheader(
|
||||
env: Sequence[str], pytester: Pytester, monkeypatch: MonkeyPatch
|
||||
) -> None:
|
||||
|
||||
@@ -224,11 +224,7 @@ class TestDoctests:
|
||||
"Traceback (most recent call last):",
|
||||
' File "*/doctest.py", line *, in __run',
|
||||
" *",
|
||||
*(
|
||||
(" *^^^^*",)
|
||||
if (3, 11, 0, "beta", 4) > sys.version_info >= (3, 11)
|
||||
else ()
|
||||
),
|
||||
*((" *^^^^*", " *", " *") if sys.version_info >= (3, 13) else ()),
|
||||
' File "<doctest test_doctest_unexpected_exception.txt[1]>", line 1, in <module>',
|
||||
"ZeroDivisionError: division by zero",
|
||||
"*/test_doctest_unexpected_exception.txt:2: UnexpectedException",
|
||||
@@ -385,7 +381,7 @@ class TestDoctests:
|
||||
"*= FAILURES =*",
|
||||
"*_ [[]doctest[]] test_doctest_linedata_on_property.Sample.some_property _*",
|
||||
"004 ",
|
||||
"005 >>> Sample().some_property",
|
||||
"005 *>>> Sample().some_property",
|
||||
"Expected:",
|
||||
" 'another thing'",
|
||||
"Got:",
|
||||
|
||||
@@ -3,7 +3,6 @@ import argparse
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import sys
|
||||
from typing import Optional
|
||||
|
||||
from _pytest.config import ExitCode
|
||||
@@ -45,32 +44,18 @@ def test_wrap_session_notify_exception(ret_exc, pytester: Pytester) -> None:
|
||||
assert result.ret == ExitCode.INTERNAL_ERROR
|
||||
assert result.stdout.lines[0] == "INTERNALERROR> Traceback (most recent call last):"
|
||||
|
||||
end_lines = (
|
||||
result.stdout.lines[-4:]
|
||||
if (3, 11, 0, "beta", 4) > sys.version_info >= (3, 11)
|
||||
else result.stdout.lines[-3:]
|
||||
)
|
||||
end_lines = result.stdout.lines[-3:]
|
||||
|
||||
if exc == SystemExit:
|
||||
assert end_lines == [
|
||||
f'INTERNALERROR> File "{c1}", line 4, in pytest_sessionstart',
|
||||
'INTERNALERROR> raise SystemExit("boom")',
|
||||
*(
|
||||
("INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^",)
|
||||
if (3, 11, 0, "beta", 4) > sys.version_info >= (3, 11)
|
||||
else ()
|
||||
),
|
||||
"INTERNALERROR> SystemExit: boom",
|
||||
]
|
||||
else:
|
||||
assert end_lines == [
|
||||
f'INTERNALERROR> File "{c1}", line 4, in pytest_sessionstart',
|
||||
'INTERNALERROR> raise ValueError("boom")',
|
||||
*(
|
||||
("INTERNALERROR> ^^^^^^^^^^^^^^^^^^^^^^^^",)
|
||||
if (3, 11, 0, "beta", 4) > sys.version_info >= (3, 11)
|
||||
else ()
|
||||
),
|
||||
"INTERNALERROR> ValueError: boom",
|
||||
]
|
||||
if returncode is False:
|
||||
|
||||
Reference in New Issue
Block a user