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

Method test_hover_with_delay

Lib/idlelib/idle_test/test_tooltip.py:111–145  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

109 self.assertGreater(len(tooltip.showtip.call_args_list), 0)
110
111 def test_hover_with_delay(self):
112 # Run multiple tests requiring an actual delay simultaneously.
113
114 # Test #1: A hover tip with a non-zero delay appears after the delay.
115 tooltip1 = Hovertip(self.button, 'ToolTip text', hover_delay=100)
116 self.addCleanup(tooltip1.hidetip)
117 tooltip1.showtip = add_call_counting(tooltip1.showtip)
118 root.update()
119 self.assertFalse(self.is_tipwindow_shown(tooltip1))
120 self.button.event_generate('<Enter>', x=0, y=0)
121 root.update()
122 self.assertFalse(self.is_tipwindow_shown(tooltip1))
123
124 # Test #2: A hover tip with a non-zero delay doesn't appear when
125 # the mouse stops hovering over the base widget before the delay
126 # expires.
127 tooltip2 = Hovertip(self.button, 'ToolTip text', hover_delay=100)
128 self.addCleanup(tooltip2.hidetip)
129 tooltip2.showtip = add_call_counting(tooltip2.showtip)
130 root.update()
131 self.button.event_generate('<Enter>', x=0, y=0)
132 root.update()
133 self.button.event_generate('<Leave>', x=0, y=0)
134 root.update()
135
136 time.sleep(0.15)
137 root.update()
138
139 # Test #1 assertions.
140 self.assertTrue(self.is_tipwindow_shown(tooltip1))
141 self.assertGreater(len(tooltip1.showtip.call_args_list), 0)
142
143 # Test #2 assertions.
144 self.assertFalse(self.is_tipwindow_shown(tooltip2))
145 self.assertEqual(tooltip2.showtip.call_args_list, [])
146
147 def test_hidetip_on_mouse_leave(self):
148 tooltip = Hovertip(self.button, 'ToolTip text', hover_delay=None)

Callers

nothing calls this directly

Calls 11

is_tipwindow_shownMethod · 0.95
HovertipClass · 0.90
add_call_countingFunction · 0.85
addCleanupMethod · 0.80
assertFalseMethod · 0.80
event_generateMethod · 0.80
assertTrueMethod · 0.80
assertGreaterMethod · 0.80
updateMethod · 0.45
sleepMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected