Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-113903: Fix an IDLE configdialog test #113973

Merged
merged 4 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Lib/idlelib/News3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Released on 2024-10-xx
=========================


gh-113903: Fix rare failure of test.test_idle, in test_configdialog.

gh-113729: Fix the "Help -> IDLE Doc" menu bug in 3.11.7 and 3.12.1.

gh-57795: Enter selected text into the Find box when opening
Expand Down
29 changes: 13 additions & 16 deletions Lib/idlelib/idle_test/test_configdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,38 +420,35 @@ def test_highlight_target_text_mouse(self):
# Set highlight_target through clicking highlight_sample.
eq = self.assertEqual
d = self.page

elem = {}
count = 0
hs = d.highlight_sample
hs.focus_force()
hs.see(1.0)
hs.update_idletasks()

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

def click_it(start):
x, y, dx, dy = hs.bbox(start)
def click_char(index):
"Simulate click on character at *index*."
hs.see(index)
hs.update_idletasks()
x, y, dx, dy = hs.bbox(index)
x += dx // 2
y += dy // 2
hs.event_generate('<Enter>', x=0, y=0)
hs.event_generate('<Motion>', x=x, y=y)
hs.event_generate('<ButtonPress-1>', x=x, y=y)
hs.event_generate('<ButtonRelease-1>', x=x, y=y)

# Flip theme_elements to make the tag the key.
tag_to_element(elem)
# Reverse theme_elements to make the tag the key.
elem = {tag: element for element, tag in d.theme_elements.items()}

# If highlight_sample has a tag that isn't in theme_elements, there
# will be a KeyError in the test run.
count = 0
for tag in hs.tag_names():
for start_index in hs.tag_ranges(tag)[0::2]:
count += 1
click_it(start_index)
try:
click_char(hs.tag_nextrange(tag, "1.0")[0])
eq(d.highlight_target.get(), elem[tag])
count += 1
eq(d.set_highlight_target.called, count)
except IndexError:
pass # Skip unused theme_elements tag, like 'sel'.

def test_highlight_sample_double_click(self):
# Test double click on highlight_sample.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix rare failure of test.test_idle, in test_configdialog.
Loading