Skip to content

Commit b75d281

Browse files
committed
pythongh-113903: Fix an IDLE configdialog test
Fix an extremely rare failure in test_highlight_target_text_mouse that happens if a line of the Highlight tab text sample is not visible. If so, bbox() in clich_char() returns None and iteration fails. Call click_char just once per tag name.
1 parent efa738e commit b75d281

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Lib/idlelib/idle_test/test_configdialog.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,15 +425,16 @@ def test_highlight_target_text_mouse(self):
425425
count = 0
426426
hs = d.highlight_sample
427427
hs.focus_force()
428-
hs.see(1.0)
429-
hs.update_idletasks()
430428

431429
def tag_to_element(elem):
432430
for element, tag in d.theme_elements.items():
433431
elem[tag] = element
434432

435-
def click_it(start):
436-
x, y, dx, dy = hs.bbox(start)
433+
def click_char(start_index):
434+
"Simulate click on character."
435+
hs.see(start_index)
436+
hs.update_idletasks()
437+
x, y, dx, dy = hs.bbox(start_index)
437438
x += dx // 2
438439
y += dy // 2
439440
hs.event_generate('<Enter>', x=0, y=0)
@@ -449,7 +450,7 @@ def click_it(start):
449450
for tag in hs.tag_names():
450451
for start_index in hs.tag_ranges(tag)[0::2]:
451452
count += 1
452-
click_it(start_index)
453+
click_char(start_index)
453454
eq(d.highlight_target.get(), elem[tag])
454455
eq(d.set_highlight_target.called, count)
455456

0 commit comments

Comments
 (0)