Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-35771: IDLE: Fix and optimize flaky tool-tip hover delay tests#15634

Merged
terryjreedy merged 6 commits into
python:masterpython/cpython:masterfrom
taleinat:bpo-35771/idle-tooltip-hover-delay-teststaleinat/cpython:bpo-35771/idle-tooltip-hover-delay-testsCopy head branch name to clipboard
Sep 3, 2019
Merged

bpo-35771: IDLE: Fix and optimize flaky tool-tip hover delay tests#15634
terryjreedy merged 6 commits into
python:masterpython/cpython:masterfrom
taleinat:bpo-35771/idle-tooltip-hover-delay-teststaleinat/cpython:bpo-35771/idle-tooltip-hover-delay-testsCopy head branch name to clipboard

Conversation

@taleinat

@taleinat taleinat commented Sep 1, 2019

Copy link
Copy Markdown
Contributor

A 50ms delay will often causes failures on slower machines.

This PR is an alternative to PR GH-14926. In this PR, both of the tests with a delay have been merged into one, to avoid multiple time.sleep() calls, reducing the overall run time.

For reference, the total run time for test_idle on my machine is about 7.5 seconds. 0.15 seconds, which is the delay time added by these tests, is 2% of that.

https://bugs.python.org/issue35771

@taleinat

taleinat commented Sep 1, 2019

Copy link
Copy Markdown
Contributor Author

@ZackerySpytz, your review would be welcome.

@terryjreedy, this is not the approach you recommended in your comment on GH-14926. IMO, in this case, it is better to actually test with Tk rather than with a mock.

@terryjreedy terryjreedy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An average speedup of .004 seconds and greatly decreased chance of spurious failure is a win. I will merge with my revisions when CI passes.

Comment thread Lib/idlelib/idle_test/test_tooltip.py Outdated
@@ -1,27 +1,31 @@
from functools import wraps

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This first few changes are irrelevant to the issue and are a regression from the 'fail fast (as soon as possible)' design used in IDLE tests. If importing the tested module fails, doing anything else is useless. If the whole module requires gui and that fails (as is does for a majority of buildbots) doing anything else is useless. I have changed back to this.

I am also adding module docstring with coverage.

Comment thread Lib/idlelib/idle_test/test_tooltip.py Outdated
global root
root.update()


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idlelib is not consitently double spaced around functions. To me, it is less needed than for classes. And PEP8 has this, which I think applies here: "Blank lines may be omitted between a bunch of related one-liners".

That aside, root_update just adds call overhead. I am replacing it.

self.top, self.button = _make_top_and_button(self)

def is_tipwindow_shown(self, tooltip):
return tooltip.tipwindow and tooltip.tipwindow.winfo_viewable()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might have used an even shorten name ('tip_shown'), but even as is, this is a definite improvement in readability.


def test_dont_show_on_mouse_leave_before_delay(self):
tooltip = Hovertip(self.button, 'ToolTip text', hover_delay=50)
time.sleep(0.15)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One sleep of .15 (to Windows accuracy of around .017) is faster than 2 sleeps of .10 (ditto).

@@ -0,0 +1,2 @@
Increase the ``hover_delay`` in IDLE's test_tooltip, and run both tests
waiting for a delay to expire simultaneously, to reduce total run time.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this to what users are more likely to want to know. "To avoid occasional spurious test_idle failures on slower machines, increase the hover_delay in test_tooltip."

@terryjreedy terryjreedy merged commit 132acab into python:master Sep 3, 2019
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @taleinat for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington

Copy link
Copy Markdown
Contributor

Sorry @taleinat and @terryjreedy, I had trouble checking out the 3.8 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 132acaba5a7f01373ca624b1a5975b190fe866f5 3.8

@bedevere-bot

Copy link
Copy Markdown

GH-15657 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 3, 2019
Extending the hover delay in test_tooltip should avoid spurious test_idle failures.
One longer delay instead of two shorter delays results in a net speedup.
(cherry picked from commit 132acab)

Co-authored-by: Tal Einat <taleinat+github@gmail.com>
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @taleinat for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

@bedevere-bot

Copy link
Copy Markdown

GH-15658 is a backport of this pull request to the 3.8 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 3, 2019
Extending the hover delay in test_tooltip should avoid spurious test_idle failures.
One longer delay instead of two shorter delays results in a net speedup.
(cherry picked from commit 132acab)

Co-authored-by: Tal Einat <taleinat+github@gmail.com>
miss-islington added a commit that referenced this pull request Sep 3, 2019
Extending the hover delay in test_tooltip should avoid spurious test_idle failures.
One longer delay instead of two shorter delays results in a net speedup.
(cherry picked from commit 132acab)

Co-authored-by: Tal Einat <taleinat+github@gmail.com>
miss-islington added a commit that referenced this pull request Sep 3, 2019
Extending the hover delay in test_tooltip should avoid spurious test_idle failures.
One longer delay instead of two shorter delays results in a net speedup.
(cherry picked from commit 132acab)

Co-authored-by: Tal Einat <taleinat+github@gmail.com>
lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
Extending the hover delay in test_tooltip should avoid spurious test_idle failures.
One longer delay instead of two shorter delays results in a net speedup.
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
Extending the hover delay in test_tooltip should avoid spurious test_idle failures.
One longer delay instead of two shorter delays results in a net speedup.
websurfer5 pushed a commit to websurfer5/cpython that referenced this pull request Jul 20, 2020
Extending the hover delay in test_tooltip should avoid spurious test_idle failures.
One longer delay instead of two shorter delays results in a net speedup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.