summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/idle_test/test_pyparse.py
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2021-01-24 19:08:50 (GMT)
committerGitHub <noreply@github.com>2021-01-24 19:08:50 (GMT)
commit8dfe15625e6ea4357a13fec7989a0e6ba2bf1359 (patch)
tree50c5397aa53f021616f370e3dfab3520eefddbd2 /Lib/idlelib/idle_test/test_pyparse.py
parent15bd9efd01e44087664e78bf766865a6d2e06626 (diff)
downloadcpython-8dfe15625e6ea4357a13fec7989a0e6ba2bf1359.zip
cpython-8dfe15625e6ea4357a13fec7989a0e6ba2bf1359.tar.gz
cpython-8dfe15625e6ea4357a13fec7989a0e6ba2bf1359.tar.bz2
bpo-43013: Update idlelib code to 3.x (GH-24315)
Remove 9 remaining '(object)' occurrences in class headers in idlelib and 25 '()' occurrences in idlelib.idle_test class headers.
Diffstat (limited to 'Lib/idlelib/idle_test/test_pyparse.py')
-rw-r--r--Lib/idlelib/idle_test/test_pyparse.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/Lib/idlelib/idle_test/test_pyparse.py b/Lib/idlelib/idle_test/test_pyparse.py
index f21baf7..fb5726d 100644
--- a/Lib/idlelib/idle_test/test_pyparse.py
+++ b/Lib/idlelib/idle_test/test_pyparse.py
@@ -73,11 +73,12 @@ class PyParseTest(unittest.TestCase):
# Split def across lines.
setcode('"""This is a module docstring"""\n'
- 'class C():\n'
+ 'class C:\n'
' def __init__(self, a,\n'
' b=True):\n'
' pass\n'
)
+ pos0, pos = 33, 42 # Start of 'class...', ' def' lines.
# Passing no value or non-callable should fail (issue 32989).
with self.assertRaises(TypeError):
@@ -91,40 +92,41 @@ 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(char_in_string_false), 44)
+ eq(start(char_in_string_false), pos)
# If the beginning of the def line is not in a string, then it
# returns that as the index.
- eq(start(is_char_in_string=lambda index: index > 44), 44)
+ eq(start(is_char_in_string=lambda index: index > pos), pos)
# If the beginning of the def line is in a string, then it
# looks for a previous index.
- eq(start(is_char_in_string=lambda index: index >= 44), 33)
+ eq(start(is_char_in_string=lambda index: index >= pos), pos0)
# If everything before the 'def' is in a string, then returns None.
# The non-continuation def line returns 44 (see below).
- eq(start(is_char_in_string=lambda index: index < 44), None)
+ eq(start(is_char_in_string=lambda index: index < pos), None)
# Code without extra line break in def line - mostly returns the same
# values.
setcode('"""This is a module docstring"""\n'
- 'class C():\n'
+ 'class C:\n'
' def __init__(self, a, b=True):\n'
' pass\n'
- )
- 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)
+ ) # Does not affect class, def positions.
+ eq(start(char_in_string_false), pos)
+ eq(start(is_char_in_string=lambda index: index > pos), pos)
+ eq(start(is_char_in_string=lambda index: index >= pos), pos0)
# When the def line isn't split, this returns which doesn't match the
# split line test.
- eq(start(is_char_in_string=lambda index: index < 44), 44)
+ eq(start(is_char_in_string=lambda index: index < pos), pos)
def test_set_lo(self):
code = (
'"""This is a module docstring"""\n'
- 'class C():\n'
+ 'class C:\n'
' def __init__(self, a,\n'
' b=True):\n'
' pass\n'
)
+ pos = 42
p = self.parser
p.set_code(code)
@@ -137,8 +139,8 @@ class PyParseTest(unittest.TestCase):
self.assertEqual(p.code, code)
# An index that is preceded by a newline.
- p.set_lo(44)
- self.assertEqual(p.code, code[44:])
+ p.set_lo(pos)
+ self.assertEqual(p.code, code[pos:])
def test_study1(self):
eq = self.assertEqual