summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/idle_test
diff options
context:
space:
mode:
authorCheryl Sabella <cheryl.sabella@gmail.com>2020-02-18 02:47:52 (GMT)
committerGitHub <noreply@github.com>2020-02-18 02:47:52 (GMT)
commitffda25f6b825f3dee493b6f0746266a4dd6989f0 (patch)
tree6e69751897cc7ced8368b0d98e1adf41aa937a90 /Lib/idlelib/idle_test
parent4c1b6a6f4fc46add0097efb3026cf3f0c89f88a2 (diff)
downloadcpython-ffda25f6b825f3dee493b6f0746266a4dd6989f0.zip
cpython-ffda25f6b825f3dee493b6f0746266a4dd6989f0.tar.gz
cpython-ffda25f6b825f3dee493b6f0746266a4dd6989f0.tar.bz2
bpo-39663: IDLE: Add additional tests for pyparse (GH-18536)
Test when find_good_parse_start should return 0. Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Diffstat (limited to 'Lib/idlelib/idle_test')
-rw-r--r--Lib/idlelib/idle_test/test_pyparse.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/Lib/idlelib/idle_test/test_pyparse.py b/Lib/idlelib/idle_test/test_pyparse.py
index a2b13c3..f21baf7 100644
--- a/Lib/idlelib/idle_test/test_pyparse.py
+++ b/Lib/idlelib/idle_test/test_pyparse.py
@@ -58,6 +58,18 @@ class PyParseTest(unittest.TestCase):
p = self.parser
setcode = p.set_code
start = p.find_good_parse_start
+ def char_in_string_false(index): return False
+
+ # First line starts with 'def' and ends with ':', then 0 is the pos.
+ setcode('def spam():\n')
+ eq(start(char_in_string_false), 0)
+
+ # First line begins with a keyword in the list and ends
+ # with an open brace, then 0 is the pos. This is how
+ # hyperparser calls this function as the newline is not added
+ # in the editor, but rather on the call to setcode.
+ setcode('class spam( ' + ' \n')
+ eq(start(char_in_string_false), 0)
# Split def across lines.
setcode('"""This is a module docstring"""\n'
@@ -79,7 +91,7 @@ class PyParseTest(unittest.TestCase):
# Make all text look like it's not in a string. This means that it
# found a good start position.
- eq(start(is_char_in_string=lambda index: False), 44)
+ eq(start(char_in_string_false), 44)
# If the beginning of the def line is not in a string, then it
# returns that as the index.
@@ -98,7 +110,7 @@ class PyParseTest(unittest.TestCase):
' def __init__(self, a, b=True):\n'
' pass\n'
)
- eq(start(is_char_in_string=lambda index: False), 44)
+ eq(start(char_in_string_false), 44)
eq(start(is_char_in_string=lambda index: index > 44), 44)
eq(start(is_char_in_string=lambda index: index >= 44), 33)
# When the def line isn't split, this returns which doesn't match the