Skip to content

Commit 1de80c0

Browse files
committed
Fix bigbuffer test
1 parent fb6ba6a commit 1de80c0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tests/test_zlib_compliance.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
1212
1313
"""
14-
14+
import os
1515
import unittest
1616
from test import support
1717
import binascii
@@ -150,7 +150,12 @@ def check_big_compress_buffer(self, size, compress_func):
150150
# Generate 10 MiB worth of random, and expand it by repeating it.
151151
# The assumption is that isal_zlib's memory is not big enough to exploit
152152
# such spread out redundancy.
153-
data = random.randbytes(_1M * 10)
153+
if hasattr(random, "randbytes"): # Available from 3.9
154+
data = random.randbytes(_1M * 10)
155+
elif hasattr(os, "urandom"):
156+
data = os.urandom(_1M * 10)
157+
else: # Test as defined in 3.6 branch of cpython as fallback.
158+
data = b'x' * _1M * 10
154159
data = data * (size // len(data) + 1)
155160
try:
156161
compress_func(data)

0 commit comments

Comments
 (0)