@@ -1886,11 +1886,8 @@ def test_write_with_source_date_epoch(self):
18861886
18871887 with zipfile .ZipFile (TESTFN , "r" ) as zf :
18881888 zip_info = zf .getinfo ("test_source_date_epoch.txt" )
1889- get_time = time .localtime (int (os .environ ['SOURCE_DATE_EPOCH' ]))[:6 ]
1890- # Compare each element of the date_time tuple
1891- # Allow for a 1-second difference
1892- for z_time , g_time in zip (zip_info .date_time , get_time ):
1893- self .assertAlmostEqual (z_time , g_time , delta = 1 )
1889+ expected_utc = (2025 , 1 , 1 , 7 , 19 , 58 )
1890+ self .assertEqual (zip_info .date_time , expected_utc )
18941891
18951892 def test_write_without_source_date_epoch (self ):
18961893 with os_helper .EnvironmentVarGuard () as env :
@@ -1901,9 +1898,13 @@ def test_write_without_source_date_epoch(self):
19011898
19021899 with zipfile .ZipFile (TESTFN , "r" ) as zf :
19031900 zip_info = zf .getinfo ("test_no_source_date_epoch.txt" )
1904- current_time = time .localtime ()[:6 ]
1905- for z_time , c_time in zip (zip_info .date_time , current_time ):
1906- self .assertAlmostEqual (z_time , c_time , delta = 2 )
1901+ self .assertTimestampAlmostEqual (time .localtime (), zip_info .date_time , tolerance = 2 )
1902+
1903+ def assertTimestampAlmostEqual (self , time1 , time2 , tolerance ):
1904+ import datetime
1905+ dt1 = datetime .datetime (* time1 [:6 ])
1906+ dt2 = datetime .datetime (* time2 [:6 ])
1907+ self .assertLessEqual ((dt1 - dt2 ).total_seconds (), tolerance )
19071908
19081909 def test_close (self ):
19091910 """Check that the zipfile is closed after the 'with' block."""
0 commit comments