summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pdb.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-07-30 09:14:20 (GMT)
committerGeorg Brandl <georg@python.org>2010-07-30 09:14:20 (GMT)
commit46b9afc862974e5855f0ca8a181096945483c86e (patch)
tree8ad8005224efaf00ef06fbb4c609b5eb6091d6ad /Lib/test/test_pdb.py
parent44f8bf941109c24d36d7d6e4dd05080a0191f3d9 (diff)
downloadcpython-46b9afc862974e5855f0ca8a181096945483c86e.zip
cpython-46b9afc862974e5855f0ca8a181096945483c86e.tar.gz
cpython-46b9afc862974e5855f0ca8a181096945483c86e.tar.bz2
#1472251: remove addition of "\n" to code given to pdb.run[eval](), the bug in exec() that made this necessary has been fixed. Also document that you can give code objects to run() and runeval(), and add some tests to test_pdb.
Diffstat (limited to 'Lib/test/test_pdb.py')
-rw-r--r--Lib/test/test_pdb.py47
1 files changed, 45 insertions, 2 deletions
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 7af903d..4af8516 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -1,5 +1,4 @@
-# A test suite for pdb; at the moment, this only validates skipping of
-# specified test modules (RFE #5142).
+# A test suite for pdb; not very comprehensive at the moment.
import imp
import sys
@@ -123,6 +122,50 @@ def test_pdb_skip_modules_with_callback():
"""
+def pdb_invoke(method, arg):
+ """Run pdb.method(arg)."""
+ import pdb; getattr(pdb, method)(arg)
+
+
+def test_pdb_run_with_incorrect_argument():
+ """Testing run and runeval with incorrect first argument.
+
+ >>> pti = PdbTestInput(['continue',])
+ >>> with pti:
+ ... pdb_invoke('run', lambda x: x)
+ Traceback (most recent call last):
+ TypeError: exec() arg 1 must be a string, bytes or code object
+
+ >>> with pti:
+ ... pdb_invoke('runeval', lambda x: x)
+ Traceback (most recent call last):
+ TypeError: eval() arg 1 must be a string, bytes or code object
+ """
+
+
+def test_pdb_run_with_code_object():
+ """Testing run and runeval with code object as a first argument.
+
+ >>> with PdbTestInput(['step','x', 'continue']):
+ ... pdb_invoke('run', compile('x=1', '<string>', 'exec'))
+ > <string>(1)<module>()
+ (Pdb) step
+ --Return--
+ > <string>(1)<module>()->None
+ (Pdb) x
+ 1
+ (Pdb) continue
+
+ >>> with PdbTestInput(['x', 'continue']):
+ ... x=0
+ ... pdb_invoke('runeval', compile('x+1', '<string>', 'eval'))
+ > <string>(1)<module>()->None
+ (Pdb) x
+ 1
+ (Pdb) continue
+ """
+
+
def test_main():
from test import test_pdb
support.run_doctest(test_pdb, verbosity=True)