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

Method test_expand

Lib/idlelib/idle_test/test_squeezer.py:349–374  ·  view source on GitHub ↗

Test the expand event.

(self)

Source from the content-addressed store, hash-verified

347 self.assertIn('right-click', tooltip_text.lower())
348
349 def test_expand(self):
350 """Test the expand event."""
351 squeezer = self.make_mock_squeezer()
352 expandingbutton = ExpandingButton('TEXT', 'TAGS', 50, squeezer)
353
354 # Insert the button into the text widget
355 # (this is normally done by the Squeezer class).
356 text_widget = squeezer.editwin.text
357 text_widget.window_create("1.0", window=expandingbutton)
358
359 # trigger the expand event
360 retval = expandingbutton.expand(event=Mock())
361 self.assertEqual(retval, None)
362
363 # Check that the text was inserted into the text widget.
364 self.assertEqual(text_widget.get('1.0', 'end'), 'TEXT\n')
365
366 # Check that the 'TAGS' tag was set on the inserted text.
367 text_end_index = text_widget.index('end-1c')
368 self.assertEqual(text_widget.get('1.0', text_end_index), 'TEXT')
369 self.assertEqual(text_widget.tag_nextrange('TAGS', '1.0'),
370 ('1.0', text_end_index))
371
372 # Check that the button removed itself from squeezer.expandingbuttons.
373 self.assertEqual(squeezer.expandingbuttons.remove.call_count, 1)
374 squeezer.expandingbuttons.remove.assert_called_with(expandingbutton)
375
376 def test_expand_dangerous_oupput(self):
377 """Test that expanding very long output asks user for confirmation."""

Callers

nothing calls this directly

Calls 10

make_mock_squeezerMethod · 0.95
expandMethod · 0.95
ExpandingButtonClass · 0.90
MockClass · 0.90
window_createMethod · 0.80
tag_nextrangeMethod · 0.80
assert_called_withMethod · 0.80
assertEqualMethod · 0.45
getMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected