gh-129192: Use EnvironmentVarGuard to restore environment variables (#129193)

Co-authored-by: Cody Maloney <cmaloney@theoreticalchaos.com>
This commit is contained in:
Kirill Podoprigora 2025-01-22 22:39:26 +02:00 committed by GitHub
parent 67d804b494
commit fc6d4b71eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1801,8 +1801,8 @@ class OtherTests(unittest.TestCase):
self.assertAlmostEqual(z_time, g_time, delta=1)
def test_write_without_source_date_epoch(self):
if 'SOURCE_DATE_EPOCH' in os.environ:
del os.environ['SOURCE_DATE_EPOCH']
with os_helper.EnvironmentVarGuard() as env:
del env['SOURCE_DATE_EPOCH']
with zipfile.ZipFile(TESTFN, "w") as zf:
zf.writestr("test_no_source_date_epoch.txt", "Testing without SOURCE_DATE_EPOCH")