]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-108418: Speed up bigmem compression tests in dry mode (GH-108419) (GH-108481)
authorSerhiy Storchaka <storchaka@gmail.com>
Fri, 25 Aug 2023 12:10:22 +0000 (15:10 +0300)
committerGitHub <noreply@github.com>
Fri, 25 Aug 2023 12:10:22 +0000 (12:10 +0000)
Only generate and compress small amount of random data in dry run.
(cherry picked from commit 4ae3edf3008b70e20663143553a736d80ff3a501)

Lib/test/test_bz2.py
Lib/test/test_lzma.py

index c97ed1cea0d113bf2842f3c50a7950ebbf9549ee..ba1c02c833847cb51bcffc242c9b6b4210dc19e8 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 145c8cfced4080bd99c72d121ac2c4e9164b9cbd..49042d7390b66d3fe531ed704de96a68e59e96b3 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)