Skip to content

tests: patch localtime in the "cert remainingdays" test#4956

Draft
evverx wants to merge 1 commit intosecdev:masterfrom
evverx:rem-days-test
Draft

tests: patch localtime in the "cert remainingdays" test#4956
evverx wants to merge 1 commit intosecdev:masterfrom
evverx:rem-days-test

Conversation

@evverx
Copy link
Copy Markdown
Contributor

@evverx evverx commented Mar 29, 2026

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.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.30%. Comparing base (2b220b9) to head (144112b).

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     

see 332 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.
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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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).

@evverx evverx marked this pull request as draft March 30, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant