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-125997: improve tests for time.sleep() #128751

Merged
merged 2 commits into from
Jan 13, 2025

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented Jan 12, 2025

@picnixz
Copy link
Member Author

picnixz commented Jan 13, 2025

@vstinner: I plan to merge this one with the following title:

Increase test coverage for `time.sleep()`.

and following commit message:

- Add tests for durations of invalid types.
- Add tests for `int` and `float` durations.
- Add tests for (signed) zeroes and durations close to the clock resolution.

Should I also add more with coverage with ns durations and for something of order 1e-16 as well? I also want to know if there's an easy way to test that a sleep has been cancelled through a signal (is there a way to exercise a Ctrl+C?)

Lib/test/test_time.py Outdated Show resolved Hide resolved
Co-authored-by: Victor Stinner <[email protected]>
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM

@picnixz picnixz merged commit b70a567 into python:main Jan 13, 2025
40 checks passed
@picnixz picnixz deleted the test/time/sleep-125997 branch January 13, 2025 16:58
@picnixz picnixz added needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes labels Jan 13, 2025
@miss-islington-app
Copy link

Thanks @picnixz for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks @picnixz for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 13, 2025
…128751)

- Add tests for durations of invalid types.
- Add tests for `int` and `float` durations, including signed zeroes durations.
- Add tests for nonzero very small durations and durations close to the clock resolution.

---------
(cherry picked from commit b70a567)

Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 13, 2025
…128751)

- Add tests for durations of invalid types.
- Add tests for `int` and `float` durations, including signed zeroes durations.
- Add tests for nonzero very small durations and durations close to the clock resolution.

---------
(cherry picked from commit b70a567)

Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Jan 13, 2025

GH-128795 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Jan 13, 2025
@bedevere-app
Copy link

bedevere-app bot commented Jan 13, 2025

GH-128796 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jan 13, 2025
@picnixz
Copy link
Member Author

picnixz commented Jan 13, 2025

I'm backporting the tests since the performance regression happened in 3.11 (if we fix that regression in the future, it'll be easier if the tests are already there)

picnixz added a commit that referenced this pull request Jan 13, 2025
… (#128795)

gh-125997: Increase test coverage for `time.sleep()` (GH-128751)

- Add tests for durations of invalid types.
- Add tests for `int` and `float` durations, including signed zeroes durations.
- Add tests for nonzero very small durations and durations close to the clock resolution.

---------
(cherry picked from commit b70a567)

Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
picnixz added a commit that referenced this pull request Jan 13, 2025
… (#128796)

gh-125997: Increase test coverage for `time.sleep()` (GH-128751)

- Add tests for durations of invalid types.
- Add tests for `int` and `float` durations, including signed zeroes durations.
- Add tests for nonzero very small durations and durations close to the clock resolution.

---------
(cherry picked from commit b70a567)

Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
@bedevere-bot

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants