mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-32989: IDLE - fix bad editor call of pyparse method (GH-5968)
Fix comments and add tests for editor newline_and_indent_event method. Remove unused None default for function parameter of pyparse find_good_parse_start method and code triggered by that default. Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This commit is contained in:
parent
8698b34b68
commit
ec64640a2c
6 changed files with 154 additions and 39 deletions
|
@ -18,7 +18,7 @@ class ParseMapTest(unittest.TestCase):
|
|||
# trans is the production instance of ParseMap, used in _study1
|
||||
parser = pyparse.Parser(4, 4)
|
||||
self.assertEqual('\t a([{b}])b"c\'d\n'.translate(pyparse.trans),
|
||||
'xxx(((x)))x"x\'x\n')
|
||||
'xxx(((x)))x"x\'x\n')
|
||||
|
||||
|
||||
class PyParseTest(unittest.TestCase):
|
||||
|
@ -61,14 +61,17 @@ class PyParseTest(unittest.TestCase):
|
|||
|
||||
# Split def across lines.
|
||||
setcode('"""This is a module docstring"""\n'
|
||||
'class C():\n'
|
||||
' def __init__(self, a,\n'
|
||||
' b=True):\n'
|
||||
' pass\n'
|
||||
)
|
||||
'class C():\n'
|
||||
' def __init__(self, a,\n'
|
||||
' b=True):\n'
|
||||
' pass\n'
|
||||
)
|
||||
|
||||
# No value sent for is_char_in_string().
|
||||
self.assertIsNone(start())
|
||||
# Passing no value or non-callable should fail (issue 32989).
|
||||
with self.assertRaises(TypeError):
|
||||
start()
|
||||
with self.assertRaises(TypeError):
|
||||
start(False)
|
||||
|
||||
# Make text look like a string. This returns pos as the start
|
||||
# position, but it's set to None.
|
||||
|
@ -91,10 +94,10 @@ class PyParseTest(unittest.TestCase):
|
|||
# Code without extra line break in def line - mostly returns the same
|
||||
# values.
|
||||
setcode('"""This is a module docstring"""\n'
|
||||
'class C():\n'
|
||||
' def __init__(self, a, b=True):\n'
|
||||
' pass\n'
|
||||
)
|
||||
'class C():\n'
|
||||
' def __init__(self, a, b=True):\n'
|
||||
' pass\n'
|
||||
)
|
||||
eq(start(is_char_in_string=lambda index: False), 44)
|
||||
eq(start(is_char_in_string=lambda index: index > 44), 44)
|
||||
eq(start(is_char_in_string=lambda index: index >= 44), 33)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue