Skip to content

Commit b28aaf9

Browse files
[3.12] gh-108418: Speed up bigmem compression tests in dry mode (GH-108419) (#108473)
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 4ae3edf) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent c5448ab commit b28aaf9

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Lib/test/test_bz2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,10 +721,10 @@ def testEOFError(self):
721721
@bigmemtest(size=_4G + 100, memuse=3.3)
722722
def testDecompress4G(self, size):
723723
# "Test BZ2Decompressor.decompress() with >4GiB input"
724-
blocksize = 10 * 1024 * 1024
724+
blocksize = min(10 * 1024 * 1024, size)
725725
block = random.randbytes(blocksize)
726726
try:
727-
data = block * (size // blocksize + 1)
727+
data = block * ((size-1) // blocksize + 1)
728728
compressed = bz2.compress(data)
729729
bz2d = BZ2Decompressor()
730730
decompressed = bz2d.decompress(compressed)

Lib/test/test_lzma.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,10 @@ def test_compressor_bigmem(self, size):
352352
@bigmemtest(size=_4G + 100, memuse=3)
353353
def test_decompressor_bigmem(self, size):
354354
lzd = LZMADecompressor()
355-
blocksize = 10 * 1024 * 1024
355+
blocksize = min(10 * 1024 * 1024, size)
356356
block = random.randbytes(blocksize)
357357
try:
358-
input = block * (size // blocksize + 1)
358+
input = block * ((size-1) // blocksize + 1)
359359
cdata = lzma.compress(input)
360360
ddata = lzd.decompress(cdata)
361361
self.assertEqual(ddata, input)

Lib/test/test_zlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,10 +989,10 @@ def testEOFError(self):
989989
@bigmemtest(size=_4G + 100, memuse=3.3)
990990
def testDecompress4G(self, size):
991991
# "Test zlib._ZlibDecompressor.decompress() with >4GiB input"
992-
blocksize = 10 * 1024 * 1024
992+
blocksize = min(10 * 1024 * 1024, size)
993993
block = random.randbytes(blocksize)
994994
try:
995-
data = block * (size // blocksize + 1)
995+
data = block * ((size-1) // blocksize + 1)
996996
compressed = zlib.compress(data)
997997
zlibd = zlib._ZlibDecompressor()
998998
decompressed = zlibd.decompress(compressed)

0 commit comments

Comments
 (0)