diff options
| author | Cheryl Sabella <cheryl.sabella@gmail.com> | 2018-06-01 19:23:00 -0400 |
|---|---|---|
| committer | Terry Jan Reedy <tjreedy@udel.edu> | 2018-06-01 19:23:00 -0400 |
| commit | 29996a1c4e8bd6dde6adce2b44d11a0982a47a3a (patch) | |
| tree | c6f08943343b54a41e9ed3da85a15325819aebf0 /Lib/idlelib/idle_test | |
| parent | 6854e803b73ac4d02ba160d514b8a53dd7a62905 (diff) | |
| download | cpython-git-29996a1c4e8bd6dde6adce2b44d11a0982a47a3a.tar.gz | |
bpo-33642: IDLE: Use variable number of lines in CodeContext. (GH-7106)
Instead of displaying a fixed number of lines, some blank, Code Context
now displays the variable number of actual context lines. When there
are no context lines, it shows a single blank line to indicate that the
feature is turned on.
The Code Context configuration option is changed from 'numlines'
(default 3) to 'maxlines' (default 15) to avoid possible interference
between user settings for the old and new versions of Code Context.
Diffstat (limited to 'Lib/idlelib/idle_test')
| -rw-r--r-- | Lib/idlelib/idle_test/test_codecontext.py | 29 | ||||
| -rw-r--r-- | Lib/idlelib/idle_test/test_configdialog.py | 2 |
2 files changed, 17 insertions, 14 deletions
diff --git a/Lib/idlelib/idle_test/test_codecontext.py b/Lib/idlelib/idle_test/test_codecontext.py index ed45828641..4c775eee6b 100644 --- a/Lib/idlelib/idle_test/test_codecontext.py +++ b/Lib/idlelib/idle_test/test_codecontext.py @@ -110,7 +110,7 @@ class CodeContextTest(unittest.TestCase): def test_reload(self): codecontext.CodeContext.reload() - self.assertEqual(self.cc.context_depth, 3) + self.assertEqual(self.cc.context_depth, 15) def test_toggle_code_context_event(self): eq = self.assertEqual @@ -127,7 +127,7 @@ class CodeContextTest(unittest.TestCase): eq(cc.label['font'], cc.textfont) eq(cc.label['fg'], cc.fgcolor) eq(cc.label['bg'], cc.bgcolor) - eq(cc.label['text'], '\n' * 2) + eq(cc.label['text'], '') # Toggle off. eq(toggle(), 'break') @@ -193,24 +193,26 @@ class CodeContextTest(unittest.TestCase): eq(cc.info, [(0, -1, '', False)]) eq(cc.topvisible, 1) + # Scroll down to line 1. + cc.text.yview(1) + cc.update_code_context() + eq(cc.info, [(0, -1, '', False)]) + eq(cc.topvisible, 2) + eq(cc.label['text'], '') + # Scroll down to line 2. cc.text.yview(2) cc.update_code_context() eq(cc.info, [(0, -1, '', False), (2, 0, 'class C1():', 'class')]) eq(cc.topvisible, 3) - # context_depth is 3 so it pads with blank lines. - eq(cc.label['text'], '\n' - '\n' - 'class C1():') + eq(cc.label['text'], 'class C1():') # Scroll down to line 3. Since it's a comment, nothing changes. cc.text.yview(3) cc.update_code_context() eq(cc.info, [(0, -1, '', False), (2, 0, 'class C1():', 'class')]) eq(cc.topvisible, 4) - eq(cc.label['text'], '\n' - '\n' - 'class C1():') + eq(cc.label['text'], 'class C1():') # Scroll down to line 4. cc.text.yview(4) @@ -219,8 +221,7 @@ class CodeContextTest(unittest.TestCase): (2, 0, 'class C1():', 'class'), (4, 4, ' def __init__(self, a, b):', 'def')]) eq(cc.topvisible, 5) - eq(cc.label['text'], '\n' - 'class C1():\n' + eq(cc.label['text'], 'class C1():\n' ' def __init__(self, a, b):') # Scroll down to line 11. Last 'def' is removed. @@ -232,7 +233,8 @@ class CodeContextTest(unittest.TestCase): (8, 8, ' if a > b:', 'if'), (10, 8, ' elif a < b:', 'elif')]) eq(cc.topvisible, 12) - eq(cc.label['text'], ' def compare(self):\n' + eq(cc.label['text'], 'class C1():\n' + ' def compare(self):\n' ' if a > b:\n' ' elif a < b:') @@ -245,7 +247,8 @@ class CodeContextTest(unittest.TestCase): (8, 8, ' if a > b:', 'if'), (10, 8, ' elif a < b:', 'elif')]) eq(cc.topvisible, 12) - eq(cc.label['text'], ' def compare(self):\n' + eq(cc.label['text'], 'class C1():\n' + ' def compare(self):\n' ' if a > b:\n' ' elif a < b:') diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py index 982dc0b7ef..26aba32c47 100644 --- a/Lib/idlelib/idle_test/test_configdialog.py +++ b/Lib/idlelib/idle_test/test_configdialog.py @@ -1170,7 +1170,7 @@ class GenPageTest(unittest.TestCase): def test_context(self): self.page.context_int.delete(0, 'end') self.page.context_int.insert(0, '1') - self.assertEqual(extpage, {'CodeContext': {'numlines': '1'}}) + self.assertEqual(extpage, {'CodeContext': {'maxlines': '1'}}) def test_source_selected(self): d = self.page |
