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>
This commit is contained in:
Terry Jan Reedy 2023-05-24 04:43:56 -04:00 committed by GitHub
parent 426950993f
commit e561c09975
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 12 deletions

View file

@ -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