pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/d3b4d3ace9db1b673d69737c740d56ab6da824b0

aa60c69660fa.css" /> gh-102980: Add tests for pdf's display, alias and where commands (GH-… · python/cpython@d3b4d3a · GitHub
Skip to content

Commit d3b4d3a

Browse files
gh-102980: Add tests for pdf's display, alias and where commands (GH-102981)
(cherry picked from commit ded9a7f) Co-authored-by: gaogaotiantian <gaogaotiantian@hotmail.com>
1 parent cbffc3a commit d3b4d3a

2 files changed

Lines changed: 151 additions & 0 deletions

File tree

Lib/test/test_pdb.py

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,156 @@ def test_pdb_whatis_command():
562562
(Pdb) continue
563563
"""
564564

565+
def test_pdb_display_command():
566+
"""Test display command
567+
568+
>>> def test_function():
569+
... a = 0
570+
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
571+
... a = 1
572+
... a = 2
573+
... a = 3
574+
... a = 4
575+
576+
>>> with PdbTestInput([ # doctest: +ELLIPSIS
577+
... 'display a',
578+
... 'n',
579+
... 'display',
580+
... 'undisplay a',
581+
... 'n',
582+
... 'display a',
583+
... 'undisplay',
584+
... 'display a < 1',
585+
... 'n',
586+
... 'continue',
587+
... ]):
588+
... test_function()
589+
> <doctest test.test_pdb.test_pdb_display_command[0]>(4)test_function()
590+
-> a = 1
591+
(Pdb) display a
592+
display a: 0
593+
(Pdb) n
594+
> <doctest test.test_pdb.test_pdb_display_command[0]>(5)test_function()
595+
-> a = 2
596+
display a: 1 [old: 0]
597+
(Pdb) display
598+
Currently displaying:
599+
a: 1
600+
(Pdb) undisplay a
601+
(Pdb) n
602+
> <doctest test.test_pdb.test_pdb_display_command[0]>(6)test_function()
603+
-> a = 3
604+
(Pdb) display a
605+
display a: 2
606+
(Pdb) undisplay
607+
(Pdb) display a < 1
608+
display a < 1: False
609+
(Pdb) n
610+
> <doctest test.test_pdb.test_pdb_display_command[0]>(7)test_function()
611+
-> a = 4
612+
(Pdb) continue
613+
"""
614+
615+
def test_pdb_alias_command():
616+
"""Test alias command
617+
618+
>>> class A:
619+
... def __init__(self):
620+
... self.attr1 = 10
621+
... self.attr2 = 'str'
622+
... def method(self):
623+
... pass
624+
625+
>>> def test_function():
626+
... o = A()
627+
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
628+
... o.method()
629+
630+
>>> with PdbTestInput([ # doctest: +ELLIPSIS
631+
... 'alias pi for k in %1.__dict__.keys(): print(f"%1.{k} = {%1.__dict__[k]}")',
632+
... 'alias ps pi self',
633+
... 'pi o',
634+
... 's',
635+
... 'ps',
636+
... 'continue',
637+
... ]):
638+
... test_function()
639+
> <doctest test.test_pdb.test_pdb_alias_command[1]>(4)test_function()
640+
-> o.method()
641+
(Pdb) alias pi for k in %1.__dict__.keys(): print(f"%1.{k} = {%1.__dict__[k]}")
642+
(Pdb) alias ps pi self
643+
(Pdb) pi o
644+
o.attr1 = 10
645+
o.attr2 = str
646+
(Pdb) s
647+
--Call--
648+
> <doctest test.test_pdb.test_pdb_alias_command[0]>(5)method()
649+
-> def method(self):
650+
(Pdb) ps
651+
self.attr1 = 10
652+
self.attr2 = str
653+
(Pdb) continue
654+
"""
655+
656+
def test_pdb_where_command():
657+
"""Test where command
658+
659+
>>> def g():
660+
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
661+
662+
>>> def f():
663+
... g();
664+
665+
>>> def test_function():
666+
... f()
667+
668+
>>> with PdbTestInput([ # doctest: +ELLIPSIS
669+
... 'w',
670+
... 'where',
671+
... 'u',
672+
... 'w',
673+
... 'continue',
674+
... ]):
675+
... test_function()
676+
--Return--
677+
> <doctest test.test_pdb.test_pdb_where_command[0]>(2)g()->None
678+
-> import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
679+
(Pdb) w
680+
...
681+
<doctest test.test_pdb.test_pdb_where_command[3]>(8)<module>()
682+
-> test_function()
683+
<doctest test.test_pdb.test_pdb_where_command[2]>(2)test_function()
684+
-> f()
685+
<doctest test.test_pdb.test_pdb_where_command[1]>(2)f()
686+
-> g();
687+
> <doctest test.test_pdb.test_pdb_where_command[0]>(2)g()->None
688+
-> import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
689+
(Pdb) where
690+
...
691+
<doctest test.test_pdb.test_pdb_where_command[3]>(8)<module>()
692+
-> test_function()
693+
<doctest test.test_pdb.test_pdb_where_command[2]>(2)test_function()
694+
-> f()
695+
<doctest test.test_pdb.test_pdb_where_command[1]>(2)f()
696+
-> g();
697+
> <doctest test.test_pdb.test_pdb_where_command[0]>(2)g()->None
698+
-> import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
699+
(Pdb) u
700+
> <doctest test.test_pdb.test_pdb_where_command[1]>(2)f()
701+
-> g();
702+
(Pdb) w
703+
...
704+
<doctest test.test_pdb.test_pdb_where_command[3]>(8)<module>()
705+
-> test_function()
706+
<doctest test.test_pdb.test_pdb_where_command[2]>(2)test_function()
707+
-> f()
708+
> <doctest test.test_pdb.test_pdb_where_command[1]>(2)f()
709+
-> g();
710+
<doctest test.test_pdb.test_pdb_where_command[0]>(2)g()->None
711+
-> import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
712+
(Pdb) continue
713+
"""
714+
565715
def test_post_mortem():
566716
"""Test post mortem traceback debugging.
567717
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve test coverage on :mod:`pdb`.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy