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

Method test_copy

Lib/idlelib/idle_test/test_squeezer.py:411–429  ·  view source on GitHub ↗

Test the copy event.

(self)

Source from the content-addressed store, hash-verified

409 self.assertEqual(expandingbutton.text.get('1.0', 'end-1c'), text)
410
411 def test_copy(self):
412 """Test the copy event."""
413 # Testing with the actual clipboard proved problematic, so this
414 # test replaces the clipboard manipulation functions with mocks
415 # and checks that they are called appropriately.
416 squeezer = self.make_mock_squeezer()
417 expandingbutton = ExpandingButton('TEXT', 'TAGS', 50, squeezer)
418 expandingbutton.clipboard_clear = Mock()
419 expandingbutton.clipboard_append = Mock()
420
421 # Trigger the copy event.
422 retval = expandingbutton.copy(event=Mock())
423 self.assertEqual(retval, None)
424
425 # Vheck that the expanding button called clipboard_clear() and
426 # clipboard_append('TEXT') once each.
427 self.assertEqual(expandingbutton.clipboard_clear.call_count, 1)
428 self.assertEqual(expandingbutton.clipboard_append.call_count, 1)
429 expandingbutton.clipboard_append.assert_called_with('TEXT')
430
431 def test_view(self):
432 """Test the view event."""

Callers

nothing calls this directly

Calls 6

make_mock_squeezerMethod · 0.95
copyMethod · 0.95
ExpandingButtonClass · 0.90
MockClass · 0.90
assert_called_withMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected