mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
bpo-43960: test_pdb resets breakpoints to make tests deterministic (GH-25691)
This commit is contained in:
parent
fdb11897d7
commit
2dc6b1789e
1 changed files with 11 additions and 7 deletions
|
@ -17,6 +17,13 @@ from test import support
|
||||||
from test.test_doctest import _FakeInput
|
from test.test_doctest import _FakeInput
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
from bdb import Breakpoint
|
||||||
|
|
||||||
|
def reset_Breakpoint():
|
||||||
|
Breakpoint.next = 1
|
||||||
|
Breakpoint.bplist = {}
|
||||||
|
Breakpoint.bpbynumber = [None]
|
||||||
|
|
||||||
|
|
||||||
class PdbTestInput(object):
|
class PdbTestInput(object):
|
||||||
"""Context manager that makes testing Pdb in doctests easier."""
|
"""Context manager that makes testing Pdb in doctests easier."""
|
||||||
|
@ -227,10 +234,7 @@ def test_pdb_breakpoint_commands():
|
||||||
First, need to clear bdb state that might be left over from previous tests.
|
First, need to clear bdb state that might be left over from previous tests.
|
||||||
Otherwise, the new breakpoints might get assigned different numbers.
|
Otherwise, the new breakpoints might get assigned different numbers.
|
||||||
|
|
||||||
>>> from bdb import Breakpoint
|
>>> reset_Breakpoint()
|
||||||
>>> Breakpoint.next = 1
|
|
||||||
>>> Breakpoint.bplist = {}
|
|
||||||
>>> Breakpoint.bpbynumber = [None]
|
|
||||||
|
|
||||||
Now test the breakpoint commands. NORMALIZE_WHITESPACE is needed because
|
Now test the breakpoint commands. NORMALIZE_WHITESPACE is needed because
|
||||||
the breakpoint list outputs a tab for the "stop only" and "ignore next"
|
the breakpoint list outputs a tab for the "stop only" and "ignore next"
|
||||||
|
@ -699,8 +703,7 @@ def test_next_until_return_at_return_event():
|
||||||
... test_function_2()
|
... test_function_2()
|
||||||
... end = 1
|
... end = 1
|
||||||
|
|
||||||
>>> from bdb import Breakpoint
|
>>> reset_Breakpoint()
|
||||||
>>> Breakpoint.next = 1
|
|
||||||
>>> with PdbTestInput(['break test_function_2',
|
>>> with PdbTestInput(['break test_function_2',
|
||||||
... 'continue',
|
... 'continue',
|
||||||
... 'return',
|
... 'return',
|
||||||
|
@ -1127,6 +1130,7 @@ def test_pdb_next_command_in_generator_for_loop():
|
||||||
... print('value', i)
|
... print('value', i)
|
||||||
... x = 123
|
... x = 123
|
||||||
|
|
||||||
|
>>> reset_Breakpoint()
|
||||||
>>> with PdbTestInput(['break test_gen',
|
>>> with PdbTestInput(['break test_gen',
|
||||||
... 'continue',
|
... 'continue',
|
||||||
... 'next',
|
... 'next',
|
||||||
|
@ -1137,7 +1141,7 @@ def test_pdb_next_command_in_generator_for_loop():
|
||||||
> <doctest test.test_pdb.test_pdb_next_command_in_generator_for_loop[1]>(3)test_function()
|
> <doctest test.test_pdb.test_pdb_next_command_in_generator_for_loop[1]>(3)test_function()
|
||||||
-> for i in test_gen():
|
-> for i in test_gen():
|
||||||
(Pdb) break test_gen
|
(Pdb) break test_gen
|
||||||
Breakpoint 6 at <doctest test.test_pdb.test_pdb_next_command_in_generator_for_loop[0]>:1
|
Breakpoint 1 at <doctest test.test_pdb.test_pdb_next_command_in_generator_for_loop[0]>:1
|
||||||
(Pdb) continue
|
(Pdb) continue
|
||||||
> <doctest test.test_pdb.test_pdb_next_command_in_generator_for_loop[0]>(2)test_gen()
|
> <doctest test.test_pdb.test_pdb_next_command_in_generator_for_loop[0]>(2)test_gen()
|
||||||
-> yield 0
|
-> yield 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue