summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/idle_test/test_editor.py
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2023-05-24 08:43:56 (GMT)
committerGitHub <noreply@github.com>2023-05-24 08:43:56 (GMT)
commite561c09975bf67ad8bb67c56a81e30a9165bcc84 (patch)
treeda94ba31879102eb4cf953e09001b679ca544f35 /Lib/idlelib/idle_test/test_editor.py
parent426950993f6a39cdf3f6a3333ac8b518833c7e61 (diff)
downloadcpython-e561c09975bf67ad8bb67c56a81e30a9165bcc84.zip
cpython-e561c09975bf67ad8bb67c56a81e30a9165bcc84.tar.gz
cpython-e561c09975bf67ad8bb67c56a81e30a9165bcc84.tar.bz2
gh-104719: IDLE - test existence of all tokenize references. (#104767)
Class editor.IndentSearcher contains all editor references to tokenize module. Module io tokenize reference cover those other modules. Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Diffstat (limited to 'Lib/idlelib/idle_test/test_editor.py')
-rw-r--r--Lib/idlelib/idle_test/test_editor.py36
1 files changed, 33 insertions, 3 deletions
diff --git a/Lib/idlelib/idle_test/test_editor.py b/Lib/idlelib/idle_test/test_editor.py
index fdb47ab..9296a6d 100644
--- a/Lib/idlelib/idle_test/test_editor.py
+++ b/Lib/idlelib/idle_test/test_editor.py
@@ -1,10 +1,10 @@
-"Test editor, coverage 35%."
+"Test editor, coverage 53%."
from idlelib import editor
import unittest
from collections import namedtuple
from test.support import requires
-from tkinter import Tk
+from tkinter import Tk, Text
Editor = editor.EditorWindow
@@ -31,7 +31,7 @@ class EditorWindowTest(unittest.TestCase):
e._close()
-class TestGetLineIndent(unittest.TestCase):
+class GetLineIndentTest(unittest.TestCase):
def test_empty_lines(self):
for tabwidth in [1, 2, 4, 6, 8]:
for line in ['', '\n']:
@@ -181,6 +181,36 @@ class IndentAndNewlineTest(unittest.TestCase):
eq(get('1.0', 'end'), ' def f1(self, a,\n \n return a + b\n')
+class IndentSearcherTest(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ requires('gui')
+ cls.root = Tk()
+ cls.root.withdraw()
+ cls.text = Text(cls.root)
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.root.destroy()
+ del cls.root
+
+ def test_searcher(self):
+ text = self.text
+ searcher = (self.text)
+ test_info = (# text, (block, indent))
+ ("", (None, None)),
+ ("[1,", (None, None)), # TokenError
+ ("if 1:\n", ('if 1:\n', None)),
+ ("if 1:\n 2\n 3\n", ('if 1:\n', ' 2\n')),
+ )
+ for code, expected_pair in test_info:
+ with self.subTest(code=code):
+ insert(text, code)
+ actual_pair = editor.IndentSearcher(text).run()
+ self.assertEqual(actual_pair, expected_pair)
+
+
class RMenuTest(unittest.TestCase):
@classmethod