Add Python 3.13 (beta1) support

This commit is contained in:
Ran Benita
2024-05-17 09:59:29 +03:00
parent dbee3fa34a
commit 1cb704ff2c
10 changed files with 45 additions and 13 deletions

View File

@@ -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:

View File

@@ -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: