diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-04-28 15:43:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-28 15:43:01 (GMT) |
commit | b52cc7c5f1a6c5b48d51cd718719a766c37d6e38 (patch) | |
tree | f8819ffd77223686326256dba2a22cc5441d194b | |
parent | ff7266efd0ef6b42dad30c9c0d210f843cc44f39 (diff) | |
download | cpython-b52cc7c5f1a6c5b48d51cd718719a766c37d6e38.zip cpython-b52cc7c5f1a6c5b48d51cd718719a766c37d6e38.tar.gz cpython-b52cc7c5f1a6c5b48d51cd718719a766c37d6e38.tar.bz2 |
bpo-43960: test_pdb resets breakpoints to make tests deterministic (GH-25691) (GH-25692)
(cherry picked from commit 2dc6b1789ec86dc80ea290fe33edd61140e47f6f)
Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
-rw-r--r-- | Lib/test/test_pdb.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index ac731fe..cdee716 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -17,6 +17,13 @@ from test import support from test.test_doctest import _FakeInput from unittest.mock import patch +from bdb import Breakpoint + +def reset_Breakpoint(): + Breakpoint.next = 1 + Breakpoint.bplist = {} + Breakpoint.bpbynumber = [None] + class PdbTestInput(object): """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. Otherwise, the new breakpoints might get assigned different numbers. - >>> from bdb import Breakpoint - >>> Breakpoint.next = 1 - >>> Breakpoint.bplist = {} - >>> Breakpoint.bpbynumber = [None] + >>> reset_Breakpoint() Now test the breakpoint commands. NORMALIZE_WHITESPACE is needed because 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() ... end = 1 - >>> from bdb import Breakpoint - >>> Breakpoint.next = 1 + >>> reset_Breakpoint() >>> with PdbTestInput(['break test_function_2', ... 'continue', ... 'return', @@ -1127,6 +1130,7 @@ def test_pdb_next_command_in_generator_for_loop(): ... print('value', i) ... x = 123 + >>> reset_Breakpoint() >>> with PdbTestInput(['break test_gen', ... 'continue', ... '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() -> for i in 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 > <doctest test.test_pdb.test_pdb_next_command_in_generator_for_loop[0]>(2)test_gen() -> yield 0 |