diff options
author | Cheryl Sabella <cheryl.sabella@gmail.com> | 2018-05-24 02:18:15 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2018-05-24 02:18:15 (GMT) |
commit | 8506016f904ba6bc27bf5261f27a0bdd5945cd26 (patch) | |
tree | 5e5229c32822a132d8c2dce377b2297916cee2d2 /Lib/idlelib/idle_test | |
parent | 8ebf5ceb0f5408d1ebc26c19702ac0762ef5ea04 (diff) | |
download | cpython-8506016f904ba6bc27bf5261f27a0bdd5945cd26.zip cpython-8506016f904ba6bc27bf5261f27a0bdd5945cd26.tar.gz cpython-8506016f904ba6bc27bf5261f27a0bdd5945cd26.tar.bz2 |
bpo-33628: IDLE: Minor code cleanup of codecontext.py and its tests (GH-7085)
Diffstat (limited to 'Lib/idlelib/idle_test')
-rw-r--r-- | Lib/idlelib/idle_test/test_codecontext.py | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/Lib/idlelib/idle_test/test_codecontext.py b/Lib/idlelib/idle_test/test_codecontext.py index 448094e..ed45828 100644 --- a/Lib/idlelib/idle_test/test_codecontext.py +++ b/Lib/idlelib/idle_test/test_codecontext.py @@ -96,8 +96,6 @@ class CodeContextTest(unittest.TestCase): eq(self.root.tk.call('after', 'info', self.cc.t2)[1], 'timer') def test_del(self): - self.root.tk.call('after', 'info', self.cc.t1) - self.root.tk.call('after', 'info', self.cc.t2) self.cc.__del__() with self.assertRaises(TclError) as msg: self.root.tk.call('after', 'info', self.cc.t1) @@ -135,21 +133,6 @@ class CodeContextTest(unittest.TestCase): eq(toggle(), 'break') self.assertIsNone(cc.label) - def test_get_line_info(self): - eq = self.assertEqual - gli = self.cc.get_line_info - - # Line 1 is not a BLOCKOPENER. - eq(gli(1), (codecontext.INFINITY, '', False)) - # Line 2 is a BLOCKOPENER without an indent. - eq(gli(2), (0, 'class C1():', 'class')) - # Line 3 is not a BLOCKOPENER and does not return the indent level. - eq(gli(3), (codecontext.INFINITY, ' # Class comment.', False)) - # Line 4 is a BLOCKOPENER and is indented. - eq(gli(4), (4, ' def __init__(self, a, b):', 'def')) - # Line 8 is a different BLOCKOPENER and is indented. - eq(gli(8), (8, ' if a > b:', 'if')) - def test_get_context(self): eq = self.assertEqual gc = self.cc.get_context @@ -323,8 +306,8 @@ class CodeContextTest(unittest.TestCase): class HelperFunctionText(unittest.TestCase): - def test_getspacesfirstword(self): - get = codecontext.getspacesfirstword + def test_get_spaces_firstword(self): + get = codecontext.get_spaces_firstword test_lines = ( (' first word', (' ', 'first')), ('\tfirst word', ('\t', 'first')), @@ -342,6 +325,24 @@ class HelperFunctionText(unittest.TestCase): c=re.compile(r'^(\s*)([^\s]*)')), (' ', '(continuation)')) + def test_get_line_info(self): + eq = self.assertEqual + gli = codecontext.get_line_info + lines = code_sample.splitlines() + + # Line 1 is not a BLOCKOPENER. + eq(gli(lines[0]), (codecontext.INFINITY, '', False)) + # Line 2 is a BLOCKOPENER without an indent. + eq(gli(lines[1]), (0, 'class C1():', 'class')) + # Line 3 is not a BLOCKOPENER and does not return the indent level. + eq(gli(lines[2]), (codecontext.INFINITY, ' # Class comment.', False)) + # Line 4 is a BLOCKOPENER and is indented. + eq(gli(lines[3]), (4, ' def __init__(self, a, b):', 'def')) + # Line 8 is a different BLOCKOPENER and is indented. + eq(gli(lines[7]), (8, ' if a > b:', 'if')) + # Test tab. + eq(gli('\tif a == b:'), (1, '\tif a == b:', 'if')) + if __name__ == '__main__': unittest.main(verbosity=2) |