summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_zlib.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_zlib.py')
-rw-r--r--Lib/test/test_zlib.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py
index 599ce24..68dd3ea 100644
--- a/Lib/test/test_zlib.py
+++ b/Lib/test/test_zlib.py
@@ -66,10 +66,6 @@ class ChecksumTestCase(unittest.TestCase):
# Issue #10276 - check that inputs >=4GB are handled correctly.
class ChecksumBigBufferTestCase(unittest.TestCase):
- @unittest.skipUnless(mmap, "mmap() is not available.")
- @unittest.skipUnless(sys.maxsize > _4G, "Can't run on a 32-bit system.")
- @unittest.skipUnless(support.is_resource_enabled("largefile"),
- "May use lots of disk space.")
def setUp(self):
with open(support.TESTFN, "wb+") as f:
f.seek(_4G)
@@ -81,6 +77,10 @@ class ChecksumBigBufferTestCase(unittest.TestCase):
self.mapping.close()
support.unlink(support.TESTFN)
+ @unittest.skipUnless(mmap, "mmap() is not available.")
+ @unittest.skipUnless(sys.maxsize > _4G, "Can't run on a 32-bit system.")
+ @unittest.skipUnless(support.is_resource_enabled("largefile"),
+ "May use lots of disk space.")
def test_big_buffer(self):
self.assertEqual(zlib.crc32(self.mapping), 3058686908)
self.assertEqual(zlib.adler32(self.mapping), 82837919)
@@ -129,7 +129,7 @@ class BaseCompressTestCase(object):
# Generate 10MB worth of random, and expand it by repeating it.
# The assumption is that zlib's memory is not big enough to exploit
# such spread out redundancy.
- data = b''.join([binascii.a2b_hex(fmt % random.getrandbits(8 * _1M))
+ data = b''.join([random.getrandbits(8 * _1M).to_bytes(_1M, 'little')
for i in range(10)])
data = data * (size // len(data) + 1)
try:
@@ -171,7 +171,7 @@ class CompressTestCase(BaseCompressTestCase, unittest.TestCase):
def test_incomplete_stream(self):
# An useful error message is given
x = zlib.compress(HAMLET_SCENE)
- self.assertRaisesRegexp(zlib.error,
+ self.assertRaisesRegex(zlib.error,
"Error -5 while decompressing data: incomplete or truncated stream",
zlib.decompress, x[:-1])
@@ -216,8 +216,8 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
y1 = dco.decompress(v1 + v2)
y2 = dco.flush()
self.assertEqual(data, y1 + y2)
- self.assertTrue(isinstance(dco.unconsumed_tail, bytes))
- self.assertTrue(isinstance(dco.unused_data, bytes))
+ self.assertIsInstance(dco.unconsumed_tail, bytes)
+ self.assertIsInstance(dco.unused_data, bytes)
def test_compressoptions(self):
# specify lots of options to compressobj()
@@ -262,7 +262,7 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
decombuf = zlib.decompress(combuf)
# Test type of return value
- self.assertTrue(isinstance(decombuf, bytes))
+ self.assertIsInstance(decombuf, bytes)
self.assertEqual(data, decombuf)
@@ -483,7 +483,7 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
data = HAMLET_SCENE
comp = zlib.compress(data)
# Test type of return value
- self.assertTrue(isinstance(comp, bytes))
+ self.assertIsInstance(comp, bytes)
d0 = zlib.decompressobj()
bufs0 = []