summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-08-27 01:17:05 (GMT)
committerGitHub <noreply@github.com>2020-08-27 01:17:05 (GMT)
commit641279e6e51b5d2e10d3fbffe6330e47c94c4bb2 (patch)
treeca3a909e02b7ea85d7c832c1147b6231f74ac8b9 /Lib/test
parent7475aa2c590e33a47f5e79e4079bca0645e93f2f (diff)
downloadcpython-641279e6e51b5d2e10d3fbffe6330e47c94c4bb2.zip
cpython-641279e6e51b5d2e10d3fbffe6330e47c94c4bb2.tar.gz
cpython-641279e6e51b5d2e10d3fbffe6330e47c94c4bb2.tar.bz2
bpo-41609: Fix output of pdb's whatis command for instance methods (GH-21935) (#21976)
(cherry picked from commit 022bc7572f061e1d1132a4db9d085b29707701e7) Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_pdb.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 0e7ae1d..9c9471a 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -425,6 +425,47 @@ def test_list_commands():
(Pdb) continue
"""
+def test_pdb_whatis_command():
+ """Test the whatis command
+
+ >>> myvar = (1,2)
+ >>> def myfunc():
+ ... pass
+
+ >>> class MyClass:
+ ... def mymethod(self):
+ ... pass
+
+ >>> def test_function():
+ ... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
+
+ >>> with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
+ ... 'whatis myvar',
+ ... 'whatis myfunc',
+ ... 'whatis MyClass',
+ ... 'whatis MyClass()',
+ ... 'whatis MyClass.mymethod',
+ ... 'whatis MyClass().mymethod',
+ ... 'continue',
+ ... ]):
+ ... test_function()
+ --Return--
+ > <doctest test.test_pdb.test_pdb_whatis_command[3]>(2)test_function()->None
+ -> import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
+ (Pdb) whatis myvar
+ <class 'tuple'>
+ (Pdb) whatis myfunc
+ Function myfunc
+ (Pdb) whatis MyClass
+ Class test.test_pdb.MyClass
+ (Pdb) whatis MyClass()
+ <class 'test.test_pdb.MyClass'>
+ (Pdb) whatis MyClass.mymethod
+ Function mymethod
+ (Pdb) whatis MyClass().mymethod
+ Method mymethod
+ (Pdb) continue
+ """
def test_post_mortem():
"""Test post mortem traceback debugging.