Fix pdb selftests on Python 3.13

Python 3.13 makes pdb break on the breakpoint() call,
rather than on the next line:
https://docs.python.org/3/whatsnew/3.13.html#pdb

Also runs the pdb tests on Python 3.13 in CI.
See #12884 for a more proper solution for that.

Fixes #12497
This commit is contained in:
Florian Bruhin 2024-10-13 14:13:51 +02:00
parent f373974707
commit f92597c664
3 changed files with 14 additions and 5 deletions

View File

@ -147,7 +147,7 @@ jobs:
- name: "ubuntu-py313"
python: "3.13-dev"
os: ubuntu-latest
tox_env: "py313"
tox_env: "py313-pexpect"
use_coverage: true
- name: "ubuntu-pypy3"
python: "pypy-3.9"

View File

@ -0,0 +1 @@
Fixed two failing pdb-related tests on Python 3.13.

View File

@ -771,9 +771,13 @@ class TestPDB:
x = 5
"""
)
if sys.version_info[:2] >= (3, 13):
break_line = "pytest.set_trace()"
else:
break_line = "x = 5"
child = pytester.spawn(f"{sys.executable} {p1}")
child.expect("x = 5")
child.expect("Pdb")
child.expect_exact(break_line)
child.expect_exact("Pdb")
child.sendeof()
self.flush(child)
@ -788,9 +792,13 @@ class TestPDB:
pass
"""
)
if sys.version_info[:2] >= (3, 13):
break_line = "pytest.set_trace()"
else:
break_line = "x = 5"
child = pytester.spawn_pytest(str(p1))
child.expect("x = 5")
child.expect("Pdb")
child.expect_exact(break_line)
child.expect_exact("Pdb")
child.sendeof()
self.flush(child)