diff options
author | Cheryl Sabella <cheryl.sabella@gmail.com> | 2018-06-08 05:21:15 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2018-06-08 05:21:15 (GMT) |
commit | 041272b657867f5bec925b19aabf23944125d49b (patch) | |
tree | 37076943947e50fa8d30193e208b94d12a2cfa59 /Lib/idlelib/idle_test | |
parent | 4aa3006619392438b0775a2f488bbe9e7a22c468 (diff) | |
download | cpython-041272b657867f5bec925b19aabf23944125d49b.zip cpython-041272b657867f5bec925b19aabf23944125d49b.tar.gz cpython-041272b657867f5bec925b19aabf23944125d49b.tar.bz2 |
bpo-33768: IDLE: Clicking on code context line moves it to top of editor (GH-7411)
Diffstat (limited to 'Lib/idlelib/idle_test')
-rw-r--r-- | Lib/idlelib/idle_test/test_codecontext.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Lib/idlelib/idle_test/test_codecontext.py b/Lib/idlelib/idle_test/test_codecontext.py index 07e10b6..2e59b85 100644 --- a/Lib/idlelib/idle_test/test_codecontext.py +++ b/Lib/idlelib/idle_test/test_codecontext.py @@ -72,6 +72,7 @@ class CodeContextTest(unittest.TestCase): del cls.root def setUp(self): + self.text.yview(0) self.cc = codecontext.CodeContext(self.editor) def tearDown(self): @@ -264,6 +265,39 @@ class CodeContextTest(unittest.TestCase): # context_depth is 1. eq(cc.context.get('1.0', 'end-1c'), ' def __init__(self, a, b):') + def test_jumptoline(self): + eq = self.assertEqual + cc = self.cc + jump = cc.jumptoline + + if not cc.context: + cc.toggle_code_context_event() + + # Empty context. + cc.text.yview(f'{2}.0') + cc.update_code_context() + eq(cc.topvisible, 2) + cc.context.mark_set('insert', '1.5') + jump() + eq(cc.topvisible, 1) + + # 4 lines of context showing. + cc.text.yview(f'{12}.0') + cc.update_code_context() + eq(cc.topvisible, 12) + cc.context.mark_set('insert', '3.0') + jump() + eq(cc.topvisible, 8) + + # More context lines than limit. + cc.context_depth = 2 + cc.text.yview(f'{12}.0') + cc.update_code_context() + eq(cc.topvisible, 12) + cc.context.mark_set('insert', '1.0') + jump() + eq(cc.topvisible, 8) + @mock.patch.object(codecontext.CodeContext, 'update_code_context') def test_timer_event(self, mock_update): # Ensure code context is not active. |