MCPcopy Index your code
hub / github.com/python/cpython / test_jumptoline

Method test_jumptoline

Lib/idlelib/idle_test/test_codecontext.py:302–341  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

300 eq(cc.context.get('1.0', 'end-1c'), ' def __init__(self, a, b):')
301
302 def test_jumptoline(self):
303 eq = self.assertEqual
304 cc = self.cc
305 jump = cc.jumptoline
306
307 if not cc.context:
308 cc.toggle_code_context_event()
309
310 # Empty context.
311 cc.text.yview('2.0')
312 cc.update_code_context()
313 eq(cc.topvisible, 2)
314 cc.context.mark_set('insert', '1.5')
315 jump()
316 eq(cc.topvisible, 1)
317
318 # 4 lines of context showing.
319 cc.text.yview('12.0')
320 cc.update_code_context()
321 eq(cc.topvisible, 12)
322 cc.context.mark_set('insert', '3.0')
323 jump()
324 eq(cc.topvisible, 8)
325
326 # More context lines than limit.
327 cc.context_depth = 2
328 cc.text.yview('12.0')
329 cc.update_code_context()
330 eq(cc.topvisible, 12)
331 cc.context.mark_set('insert', '1.0')
332 jump()
333 eq(cc.topvisible, 8)
334
335 # Context selection stops jump.
336 cc.text.yview('5.0')
337 cc.update_code_context()
338 cc.context.tag_add('sel', '1.0', '2.0')
339 cc.context.mark_set('insert', '1.0')
340 jump() # Without selection, to line 2.
341 eq(cc.topvisible, 5)
342
343 @mock.patch.object(codecontext.CodeContext, 'update_code_context')
344 def test_timer_event(self, mock_update):

Callers

nothing calls this directly

Calls 7

eqFunction · 0.85
jumpFunction · 0.85
update_code_contextMethod · 0.80
tag_addMethod · 0.80
yviewMethod · 0.45
mark_setMethod · 0.45

Tested by

no test coverage detected