]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-108418: Speed up bigmem compression tests in dry mode (GH-108419) (#108473)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 25 Aug 2023 16:22:06 +0000 (09:22 -0700)
committerGitHub <noreply@github.com>
Fri, 25 Aug 2023 16:22:06 +0000 (18:22 +0200)
gh-108418: Speed up bigmem compression tests in dry mode (GH-108419)

Only generate and compress small amount of random data in dry run.
(cherry picked from commit 4ae3edf3008b70e20663143553a736d80ff3a501)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/test/test_bz2.py
Lib/test/test_lzma.py
Lib/test/test_zlib.py

index e4dd7fc2100b6277c8707a8f6b7c92b988382dfe..1f0b9adc3698b4ad9a7202ee813e3d7411cdbb61 100644 (file)
@@ -721,10 +721,10 @@ class BZ2DecompressorTest(BaseTest):
     @bigmemtest(size=_4G + 100, memuse=3.3)
     def testDecompress4G(self, size):
         # "Test BZ2Decompressor.decompress() with >4GiB input"
-        blocksize = 10 * 1024 * 1024
+        blocksize = min(10 * 1024 * 1024, size)
         block = random.randbytes(blocksize)
         try:
-            data = block * (size // blocksize + 1)
+            data = block * ((size-1) // blocksize + 1)
             compressed = bz2.compress(data)
             bz2d = BZ2Decompressor()
             decompressed = bz2d.decompress(compressed)
index ac53bdda2f174742e787aedcbf59cf01daad9d39..13b200912f6abda4019fa3705a6505d066d43a2e 100644 (file)
@@ -352,10 +352,10 @@ class CompressorDecompressorTestCase(unittest.TestCase):
     @bigmemtest(size=_4G + 100, memuse=3)
     def test_decompressor_bigmem(self, size):
         lzd = LZMADecompressor()
-        blocksize = 10 * 1024 * 1024
+        blocksize = min(10 * 1024 * 1024, size)
         block = random.randbytes(blocksize)
         try:
-            input = block * (size // blocksize + 1)
+            input = block * ((size-1) // blocksize + 1)
             cdata = lzma.compress(input)
             ddata = lzd.decompress(cdata)
             self.assertEqual(ddata, input)
index 2113757254c0ed920db133f9107399a914a9f62d..55306c63cd4e16828842113892fd47098a981976 100644 (file)
@@ -989,10 +989,10 @@ class ZlibDecompressorTest(unittest.TestCase):
     @bigmemtest(size=_4G + 100, memuse=3.3)
     def testDecompress4G(self, size):
         # "Test zlib._ZlibDecompressor.decompress() with >4GiB input"
-        blocksize = 10 * 1024 * 1024
+        blocksize = min(10 * 1024 * 1024, size)
         block = random.randbytes(blocksize)
         try:
-            data = block * (size // blocksize + 1)
+            data = block * ((size-1) // blocksize + 1)
             compressed = zlib.compress(data)
             zlibd = zlib._ZlibDecompressor()
             decompressed = zlibd.decompress(compressed)