Make tests pass some more years#3045
Conversation
Without this patch, tests fail after 2024-11-25. Background: As part of my work on reproducible builds for openSUSE, I check that software still gives identical build results in the future. The usual offset is +16 years, because that is how long I expect some software will be used in some places. This showed up failing tests in our python-PyGithub package build. See https://reproducible-builds.org/ for why this matters.
|
These expiration timestamps are evaluated server-side. I think there is no issue with the tests past this time. Have you tested this breaks with local time changed past that date? |
|
Yes, that is how I found this. |
|
Then we should mock the clock used by diff --git a/tests/Authentication.py b/tests/Authentication.py
index ffd419c6..071a2147 100644
--- a/tests/Authentication.py
+++ b/tests/Authentication.py
@@ -176,16 +176,15 @@ class Authentication(Framework.BasicTestCase):
installation_auth = github.Auth.AppInstallationAuth(self.app_auth, 29782936)
g = github.Github(auth=installation_auth)
- # test token expiry
# token expires 2024-11-25 01:00:02
token = installation_auth.token
- self.assertFalse(installation_auth._is_expired)
self.assertEqual(
installation_auth._AppInstallationAuth__installation_authorization.expires_at,
datetime(2024, 11, 25, 1, 0, 2, tzinfo=timezone.utc),
)
- # forward the clock so token expires
+ # test token expiry
+ # control the current time used by _is_expired
with mock.patch("github.Auth.datetime") as dt:
# just before expiry
dt.now = mock.Mock(return_value=datetime(2024, 11, 25, 0, 59, 3, tzinfo=timezone.utc)) |
|
OK. I can test your patch. |
|
I tried that patch and got a different error/trace: |
|
There is around one month left to solve this. What are the plans? |
Probably because you did not revert your changes of the replay data. Reverting your commit and applying the proposed patch fixes the issue. |
|
You can have a look at It does not throw the assertion with the current date. |
|
Looking more closely at the test log, the problem seems to be that it tries to connect a live server, but our builds run without access to the internet. So maybe something wrong with the mocking? |
|
Of course, using the token has to be guarded against real time as well: 6898f52 How is this now? |
|
Yes, that makes it pass. |
|
Can we please get a new release well ahead of 2024-11-25 ? |
|
Why is that? |
|
So that we (openSUSE and all other distributions) don't need to cherry-pick this patch onto our 2.4.0 package. |
|
Do you execute unit tests in your pipeline? |
|
Released as v2.5.0. |
Without this patch, tests fail after 2024-11-25.
Background:
As part of my work on reproducible builds for openSUSE, I check that software still gives identical build results in the future.
The usual offset is +16 years, because that is how long I expect some software will be used in some places.
This showed up failing tests in our python-PyGithub package build.
See https://reproducible-builds.org/ for why this matters.