bpo-33642: IDLE: Use variable number of lines in CodeContext. (GH-7106) · python/cpython@29996a1
@@ -110,7 +110,7 @@ def test_del(self):
110110111111def test_reload(self):
112112codecontext.CodeContext.reload()
113-self.assertEqual(self.cc.context_depth, 3)
113+self.assertEqual(self.cc.context_depth, 15)
114114115115def test_toggle_code_context_event(self):
116116eq = self.assertEqual
@@ -127,7 +127,7 @@ def test_toggle_code_context_event(self):
127127eq(cc.label['font'], cc.textfont)
128128eq(cc.label['fg'], cc.fgcolor)
129129eq(cc.label['bg'], cc.bgcolor)
130-eq(cc.label['text'], '\n' * 2)
130+eq(cc.label['text'], '')
131131132132# Toggle off.
133133eq(toggle(), 'break')
@@ -193,24 +193,26 @@ def test_update_code_context(self):
193193eq(cc.info, [(0, -1, '', False)])
194194eq(cc.topvisible, 1)
195195196+# Scroll down to line 1.
197+cc.text.yview(1)
198+cc.update_code_context()
199+eq(cc.info, [(0, -1, '', False)])
200+eq(cc.topvisible, 2)
201+eq(cc.label['text'], '')
202+196203# Scroll down to line 2.
197204cc.text.yview(2)
198205cc.update_code_context()
199206eq(cc.info, [(0, -1, '', False), (2, 0, 'class C1():', 'class')])
200207eq(cc.topvisible, 3)
201-# context_depth is 3 so it pads with blank lines.
202-eq(cc.label['text'], '\n'
203-'\n'
204-'class C1():')
208+eq(cc.label['text'], 'class C1():')
205209206210# Scroll down to line 3. Since it's a comment, nothing changes.
207211cc.text.yview(3)
208212cc.update_code_context()
209213eq(cc.info, [(0, -1, '', False), (2, 0, 'class C1():', 'class')])
210214eq(cc.topvisible, 4)
211-eq(cc.label['text'], '\n'
212-'\n'
213-'class C1():')
215+eq(cc.label['text'], 'class C1():')
214216215217# Scroll down to line 4.
216218cc.text.yview(4)
@@ -219,8 +221,7 @@ def test_update_code_context(self):
219221 (2, 0, 'class C1():', 'class'),
220222 (4, 4, ' def __init__(self, a, b):', 'def')])
221223eq(cc.topvisible, 5)
222-eq(cc.label['text'], '\n'
223-'class C1():\n'
224+eq(cc.label['text'], 'class C1():\n'
224225' def __init__(self, a, b):')
225226226227# Scroll down to line 11. Last 'def' is removed.
@@ -232,7 +233,8 @@ def test_update_code_context(self):
232233 (8, 8, ' if a > b:', 'if'),
233234 (10, 8, ' elif a < b:', 'elif')])
234235eq(cc.topvisible, 12)
235-eq(cc.label['text'], ' def compare(self):\n'
236+eq(cc.label['text'], 'class C1():\n'
237+' def compare(self):\n'
236238' if a > b:\n'
237239' elif a < b:')
238240@@ -245,7 +247,8 @@ def test_update_code_context(self):
245247 (8, 8, ' if a > b:', 'if'),
246248 (10, 8, ' elif a < b:', 'elif')])
247249eq(cc.topvisible, 12)
248-eq(cc.label['text'], ' def compare(self):\n'
250+eq(cc.label['text'], 'class C1():\n'
251+' def compare(self):\n'
249252' if a > b:\n'
250253' elif a < b:')
251254