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

Method test_init

Lib/idlelib/idle_test/test_squeezer.py:321–347  ·  view source on GitHub ↗

Test the simplest creation of an ExpandingButton.

(self, MockHovertip)

Source from the content-addressed store, hash-verified

319
320 @patch('idlelib.squeezer.Hovertip', autospec=Hovertip)
321 def test_init(self, MockHovertip):
322 """Test the simplest creation of an ExpandingButton."""
323 squeezer = self.make_mock_squeezer()
324 text_widget = squeezer.editwin.text
325
326 expandingbutton = ExpandingButton('TEXT', 'TAGS', 50, squeezer)
327 self.assertEqual(expandingbutton.s, 'TEXT')
328
329 # Check that the underlying tkinter.Button is properly configured.
330 self.assertEqual(expandingbutton.master, text_widget)
331 self.assertTrue('50 lines' in expandingbutton.cget('text'))
332
333 # Check that the text widget still contains no text.
334 self.assertEqual(text_widget.get('1.0', 'end'), '\n')
335
336 # Check that the mouse events are bound.
337 self.assertIn('<Double-Button-1>', expandingbutton.bind())
338 right_button_code = '<Button-%s>' % ('2' if macosx.isAquaTk() else '3')
339 self.assertIn(right_button_code, expandingbutton.bind())
340
341 # Check that ToolTip was called once, with appropriate values.
342 self.assertEqual(MockHovertip.call_count, 1)
343 MockHovertip.assert_called_with(expandingbutton, ANY, hover_delay=ANY)
344
345 # Check that 'right-click' appears in the tooltip text.
346 tooltip_text = MockHovertip.call_args[0][1]
347 self.assertIn('right-click', tooltip_text.lower())
348
349 def test_expand(self):
350 """Test the expand event."""

Callers

nothing calls this directly

Calls 10

make_mock_squeezerMethod · 0.95
ExpandingButtonClass · 0.90
assertTrueMethod · 0.80
assertInMethod · 0.80
assert_called_withMethod · 0.80
assertEqualMethod · 0.45
cgetMethod · 0.45
getMethod · 0.45
bindMethod · 0.45
lowerMethod · 0.45

Tested by

no test coverage detected