tests: patch localtime in the "cert remainingdays" test#4956
Draft
evverx wants to merge 1 commit intosecdev:masterfrom
Draft
tests: patch localtime in the "cert remainingdays" test#4956evverx wants to merge 1 commit intosecdev:masterfrom
evverx wants to merge 1 commit intosecdev:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4956 +/- ##
===========================================
+ Coverage 47.61% 80.30% +32.69%
===========================================
Files 361 379 +18
Lines 92766 93107 +341
===========================================
+ Hits 44170 74772 +30602
+ Misses 48596 18335 -30261 🚀 New features to boost your workflow:
|
to make sure the code where the invalid timezone is passed to exercise the localtime code path doesn't fail as time goes by. The other test was added to exercise the code path where the second format is passed.
evverx
commented
Mar 30, 2026
| import time | ||
|
|
||
| with patch('time.localtime', return_value=time.struct_time((2026, 3, 1, 0, 0, 0, 6, 60, 0))): | ||
| assert abs(x.remainingDays("Feb 12 10:00:00 2011 Paris, Madrid")) > 1 |
Contributor
Author
There was a problem hiding this comment.
Having thought about this I think it would probably be better to fail in cases like this (but it wouldn't be backward-compatible). The test itself should probably be changed now that the date is fixed. I'd pin it to Apr 1, drop abs and check that remainingDays < 0 or something like that. I'll convert it to draft for now.
(that being said it should be fine to unblock downstream CI like pyca/cryptography#14563 and can be polished later. I'm not sure).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
to make sure the code where the invalid timezone is passed to exercise the localtime code path doesn't fail as time goes by.
The other test was added to exercise the code path where the second format is passed.