mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
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>
This commit is contained in:
parent
4c1b6a6f4f
commit
ffda25f6b8
3 changed files with 17 additions and 2 deletions
|
@ -3,6 +3,8 @@ Released on 2020-10-05?
|
||||||
======================================
|
======================================
|
||||||
|
|
||||||
|
|
||||||
|
bpo-39663: Add tests for pyparse find_good_parse_start().
|
||||||
|
|
||||||
bpo-39600: Remove duplicate font names from configuration list.
|
bpo-39600: Remove duplicate font names from configuration list.
|
||||||
|
|
||||||
bpo-38792: Close a shell calltip if a :exc:`KeyboardInterrupt`
|
bpo-38792: Close a shell calltip if a :exc:`KeyboardInterrupt`
|
||||||
|
|
|
@ -58,6 +58,18 @@ class PyParseTest(unittest.TestCase):
|
||||||
p = self.parser
|
p = self.parser
|
||||||
setcode = p.set_code
|
setcode = p.set_code
|
||||||
start = p.find_good_parse_start
|
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.
|
# Split def across lines.
|
||||||
setcode('"""This is a module docstring"""\n'
|
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
|
# Make all text look like it's not in a string. This means that it
|
||||||
# found a good start position.
|
# 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
|
# If the beginning of the def line is not in a string, then it
|
||||||
# returns that as the index.
|
# returns that as the index.
|
||||||
|
@ -98,7 +110,7 @@ class PyParseTest(unittest.TestCase):
|
||||||
' def __init__(self, a, b=True):\n'
|
' def __init__(self, a, b=True):\n'
|
||||||
' pass\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), 44)
|
||||||
eq(start(is_char_in_string=lambda index: index >= 44), 33)
|
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
|
# When the def line isn't split, this returns which doesn't match the
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Add tests for pyparse find_good_parse_start().
|
Loading…
Add table
Add a link
Reference in a new issue