summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pdb.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2013-10-13 18:51:47 (GMT)
committerGeorg Brandl <georg@python.org>2013-10-13 18:51:47 (GMT)
commit6e22055ee1d2fa4c93abfafc0ab4029b4a808eb7 (patch)
treed63762099e0496dab07549e90fbc8f5f8c258bb8 /Lib/test/test_pdb.py
parent7ff4520584d18f44f230a92c20a8091297bc08a8 (diff)
downloadcpython-6e22055ee1d2fa4c93abfafc0ab4029b4a808eb7.zip
cpython-6e22055ee1d2fa4c93abfafc0ab4029b4a808eb7.tar.gz
cpython-6e22055ee1d2fa4c93abfafc0ab4029b4a808eb7.tar.bz2
pdb: modernize find_function() and add tests for it.
Closes #18714.
Diffstat (limited to 'Lib/test/test_pdb.py')
-rw-r--r--Lib/test/test_pdb.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index e17f933..7993d02 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -620,6 +620,36 @@ class PdbTestCase(unittest.TestCase):
stderr = stderr and bytes.decode(stderr)
return stdout, stderr
+ def _assert_find_function(self, file_content, func_name, expected):
+ file_content = textwrap.dedent(file_content)
+
+ with open(support.TESTFN, 'w') as f:
+ f.write(file_content)
+
+ expected = None if not expected else (
+ expected[0], support.TESTFN, expected[1])
+ self.assertEqual(
+ expected, pdb.find_function(func_name, support.TESTFN))
+
+ def test_find_function_empty_file(self):
+ self._assert_find_function('', 'foo', None)
+
+ def test_find_function_found(self):
+ self._assert_find_function(
+ """\
+ def foo():
+ pass
+
+ def bar():
+ pass
+
+ def quux():
+ pass
+ """,
+ 'bar',
+ ('bar', 4),
+ )
+
def test_issue7964(self):
# open the file as binary so we can force \r\n newline
with open(support.TESTFN, 'wb') as f: