aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_gzip.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_gzip.py')
-rw-r--r--Lib/test/test_gzip.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py
index ae384c3849d..bf6e1703db8 100644
--- a/Lib/test/test_gzip.py
+++ b/Lib/test/test_gzip.py
@@ -713,6 +713,17 @@ class TestGzip(BaseTest):
f.read(1) # to set mtime attribute
self.assertEqual(f.mtime, mtime)
+ def test_compress_mtime_default(self):
+ # test for gh-125260
+ datac = gzip.compress(data1, mtime=0)
+ datac2 = gzip.compress(data1)
+ self.assertEqual(datac, datac2)
+ datac3 = gzip.compress(data1, mtime=None)
+ self.assertNotEqual(datac, datac3)
+ with gzip.GzipFile(fileobj=io.BytesIO(datac3), mode="rb") as f:
+ f.read(1) # to set mtime attribute
+ self.assertGreater(f.mtime, 1)
+
def test_compress_correct_level(self):
for mtime in (0, 42):
with self.subTest(mtime=mtime):