Skip to content

Commit

Permalink
Fix pdb selftests on Python 3.13
Browse files Browse the repository at this point in the history
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 pytest-dev#12884 for a more proper solution for that.

Fixes pytest-dev#12497
  • Loading branch information
The-Compiler committed Oct 13, 2024
1 parent f373974 commit f92597c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions changelog/12497.contrib.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed two failing pdb-related tests on Python 3.13.
16 changes: 12 additions & 4 deletions testing/test_debugging.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,13 @@ def test_pdb_used_outside_test(self, pytester: Pytester) -> None:
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)

Expand All @@ -788,9 +792,13 @@ def test_foo(a):
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)

Expand Down

0 comments on commit f92597c

Please sign in to comment.