Skip to content

Commit f92597c

Browse files
committed
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
1 parent f373974 commit f92597c

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ jobs:
147147
- name: "ubuntu-py313"
148148
python: "3.13-dev"
149149
os: ubuntu-latest
150-
tox_env: "py313"
150+
tox_env: "py313-pexpect"
151151
use_coverage: true
152152
- name: "ubuntu-pypy3"
153153
python: "pypy-3.9"

changelog/12497.contrib.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed two failing pdb-related tests on Python 3.13.

testing/test_debugging.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -771,9 +771,13 @@ def test_pdb_used_outside_test(self, pytester: Pytester) -> None:
771771
x = 5
772772
"""
773773
)
774+
if sys.version_info[:2] >= (3, 13):
775+
break_line = "pytest.set_trace()"
776+
else:
777+
break_line = "x = 5"
774778
child = pytester.spawn(f"{sys.executable} {p1}")
775-
child.expect("x = 5")
776-
child.expect("Pdb")
779+
child.expect_exact(break_line)
780+
child.expect_exact("Pdb")
777781
child.sendeof()
778782
self.flush(child)
779783

@@ -788,9 +792,13 @@ def test_foo(a):
788792
pass
789793
"""
790794
)
795+
if sys.version_info[:2] >= (3, 13):
796+
break_line = "pytest.set_trace()"
797+
else:
798+
break_line = "x = 5"
791799
child = pytester.spawn_pytest(str(p1))
792-
child.expect("x = 5")
793-
child.expect("Pdb")
800+
child.expect_exact(break_line)
801+
child.expect_exact("Pdb")
794802
child.sendeof()
795803
self.flush(child)
796804

0 commit comments

Comments
 (0)