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

tests: Use freezegun for time mocking to fix pypy3 compatibility #2716

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

mgorny
Copy link
Contributor

@mgorny mgorny commented Oct 9, 2024

Description of the changes being introduced by the pull request:

Use freezegun for time mocking instead of manually patching the datetime module, as it provides a more streamlined solution that works both on CPython and on PyPy. Unfortunately, due to differences between the C datetime extension used by CPython, and the pure Python version of datetime (used by PyPy, and as a fallback on CPython), there does not seem to be a trivial way to mock time that would work with both versions.

Fixes #2708

Use freezegun for time mocking instead of manually patching the datetime
module, as it provides a more streamlined solution that works both
on CPython and on PyPy.  Unfortunately, due to differences between
the C datetime extension used by CPython, and the pure Python version
of datetime (used by PyPy, and as a fallback on CPython), there does not
seem to be a trivial way to mock time that would work with both
versions.

Fixes theupdateframework#2708

Signed-off-by: Michał Górny <[email protected]>
Comment on lines +12 to +13
# Required for type stubs
freezegun==1.5.1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

By the way, for a similar reason (and especially that types can effectively be different across Python versions), I've switched typing checks in my private projects from "linting" environment to the main test environment, and therefore I run them for every impl separately.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 11254491555

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 96.805%

Totals Coverage Status
Change from base Build 11230466329: 0.0%
Covered Lines: 1554
Relevant Lines: 1591

💛 - Coveralls

Copy link
Member

@jku jku left a comment

Choose a reason for hiding this comment

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

Thanks, this looks good to me

@kairoaraujo kairoaraujo self-requested a review October 9, 2024 13:42
@jku jku merged commit cf05c11 into theupdateframework:develop Oct 10, 2024
16 checks passed
@mgorny mgorny deleted the freezegun branch October 10, 2024 11:08
@mgorny
Copy link
Contributor Author

mgorny commented Oct 10, 2024

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants