Skip to content

Commit a16de5d

Browse files
Issue #23821: Fixed test_pdb failure under -O.
1 parent c512adc commit a16de5d

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

Lib/test/test_pdb.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -677,10 +677,12 @@ def test_pdb_next_command_for_generator():
677677
... import pdb; pdb.Pdb(nosigint=True).set_trace()
678678
... it = test_gen()
679679
... try:
680-
... assert next(it) == 0
680+
... if next(it) != 0:
681+
... raise AssertionError
681682
... next(it)
682683
... except StopIteration as ex:
683-
... assert ex.value == 1
684+
... if ex.value != 1:
685+
... raise AssertionError
684686
... print("finished")
685687
686688
>>> with PdbTestInput(['step',
@@ -699,7 +701,7 @@ def test_pdb_next_command_for_generator():
699701
-> try:
700702
(Pdb) step
701703
> <doctest test.test_pdb.test_pdb_next_command_for_generator[1]>(5)test_function()
702-
-> assert next(it) == 0
704+
-> if next(it) != 0:
703705
(Pdb) step
704706
--Call--
705707
> <doctest test.test_pdb.test_pdb_next_command_for_generator[0]>(1)test_gen()
@@ -716,7 +718,7 @@ def test_pdb_next_command_for_generator():
716718
-> return 1
717719
(Pdb) step
718720
StopIteration: 1
719-
> <doctest test.test_pdb.test_pdb_next_command_for_generator[1]>(6)test_function()
721+
> <doctest test.test_pdb.test_pdb_next_command_for_generator[1]>(7)test_function()
720722
-> next(it)
721723
(Pdb) continue
722724
finished
@@ -735,10 +737,12 @@ def test_pdb_return_command_for_generator():
735737
... import pdb; pdb.Pdb(nosigint=True).set_trace()
736738
... it = test_gen()
737739
... try:
738-
... assert next(it) == 0
740+
... if next(it) != 0:
741+
... raise AssertionError
739742
... next(it)
740743
... except StopIteration as ex:
741-
... assert ex.value == 1
744+
... if ex.value != 1:
745+
... raise AssertionError
742746
... print("finished")
743747
744748
>>> with PdbTestInput(['step',
@@ -756,21 +760,21 @@ def test_pdb_return_command_for_generator():
756760
-> try:
757761
(Pdb) step
758762
> <doctest test.test_pdb.test_pdb_return_command_for_generator[1]>(5)test_function()
759-
-> assert next(it) == 0
763+
-> if next(it) != 0:
760764
(Pdb) step
761765
--Call--
762766
> <doctest test.test_pdb.test_pdb_return_command_for_generator[0]>(1)test_gen()
763767
-> def test_gen():
764768
(Pdb) return
765769
StopIteration: 1
766-
> <doctest test.test_pdb.test_pdb_return_command_for_generator[1]>(6)test_function()
770+
> <doctest test.test_pdb.test_pdb_return_command_for_generator[1]>(7)test_function()
767771
-> next(it)
768772
(Pdb) step
769-
> <doctest test.test_pdb.test_pdb_return_command_for_generator[1]>(7)test_function()
773+
> <doctest test.test_pdb.test_pdb_return_command_for_generator[1]>(8)test_function()
770774
-> except StopIteration as ex:
771775
(Pdb) step
772-
> <doctest test.test_pdb.test_pdb_return_command_for_generator[1]>(8)test_function()
773-
-> assert ex.value == 1
776+
> <doctest test.test_pdb.test_pdb_return_command_for_generator[1]>(9)test_function()
777+
-> if ex.value != 1:
774778
(Pdb) continue
775779
finished
776780
"""

0 commit comments

Comments
 (0)