Skip to content

Commit 352c55a

Browse files
Make tests pass some more years (PyGithub#3045)
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. --------- Co-authored-by: Enrico Minack <[email protected]>
1 parent cf44395 commit 352c55a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

tests/Authentication.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,15 @@ def testAppInstallationAuthAuthentication(self):
176176
installation_auth = github.Auth.AppInstallationAuth(self.app_auth, 29782936)
177177
g = github.Github(auth=installation_auth)
178178

179-
# test token expiry
180179
# token expires 2024-11-25 01:00:02
181180
token = installation_auth.token
182-
self.assertFalse(installation_auth._is_expired)
183181
self.assertEqual(
184182
installation_auth._AppInstallationAuth__installation_authorization.expires_at,
185183
datetime(2024, 11, 25, 1, 0, 2, tzinfo=timezone.utc),
186184
)
187185

188-
# forward the clock so token expires
186+
# test token expiry
187+
# control the current time used by _is_expired
189188
with mock.patch("github.Auth.datetime") as dt:
190189
# just before expiry
191190
dt.now = mock.Mock(return_value=datetime(2024, 11, 25, 0, 59, 3, tzinfo=timezone.utc))
@@ -204,9 +203,9 @@ def testAppInstallationAuthAuthentication(self):
204203
datetime(2025, 11, 25, 1, 0, 2, tzinfo=timezone.utc),
205204
)
206205

207-
# use the token
208-
self.assertEqual(g.get_user("ammarmallik").name, "Ammar Akbar")
209-
self.assertEqual(g.get_repo("PyGithub/PyGithub").full_name, "PyGithub/PyGithub")
206+
# use the token
207+
self.assertEqual(g.get_user("ammarmallik").name, "Ammar Akbar")
208+
self.assertEqual(g.get_repo("PyGithub/PyGithub").full_name, "PyGithub/PyGithub")
210209

211210
def testAppInstallationAuthAuthenticationRequesterArgs(self):
212211
installation_auth = github.Auth.AppInstallationAuth(self.app_auth, 29782936)

0 commit comments

Comments
 (0)