MCPcopy Index your code
hub / github.com/python/cpython / test_decompress_parameters

Method test_decompress_parameters

Lib/test/test_zstd.py:548–590  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

546 lzd.decompress(empty)
547
548 def test_decompress_parameters(self):
549 d = {DecompressionParameter.window_log_max : 15}
550 ZstdDecompressor(options=d)
551
552 d1 = d.copy()
553 # larger than signed int
554 d1[DecompressionParameter.window_log_max] = 2**1000
555 with self.assertRaises(OverflowError):
556 ZstdDecompressor(None, d1)
557 # smaller than signed int
558 d1[DecompressionParameter.window_log_max] = -(2**1000)
559 with self.assertRaises(OverflowError):
560 ZstdDecompressor(None, d1)
561
562 d1[DecompressionParameter.window_log_max] = C_INT_MAX
563 with self.assertRaises(ValueError):
564 ZstdDecompressor(None, d1)
565 d1[DecompressionParameter.window_log_max] = C_INT_MIN
566 with self.assertRaises(ValueError):
567 ZstdDecompressor(None, d1)
568
569 # out of bounds error msg
570 options = {DecompressionParameter.window_log_max:100}
571 with self.assertRaisesRegex(
572 ValueError,
573 "decompression parameter 'window_log_max' received an illegal value 100; "
574 r'the valid range is \[-?\d+, -?\d+\]',
575 ):
576 decompress(b'', options=options)
577
578 # out of bounds deecompression parameter
579 options[DecompressionParameter.window_log_max] = C_INT_MAX
580 with self.assertRaises(ValueError):
581 decompress(b'', options=options)
582 options[DecompressionParameter.window_log_max] = C_INT_MIN
583 with self.assertRaises(ValueError):
584 decompress(b'', options=options)
585 options[DecompressionParameter.window_log_max] = 2**1000
586 with self.assertRaises(OverflowError):
587 decompress(b'', options=options)
588 options[DecompressionParameter.window_log_max] = -(2**1000)
589 with self.assertRaises(OverflowError):
590 decompress(b'', options=options)
591
592 def test_unknown_decompression_parameter(self):
593 KEY = 100001234

Callers

nothing calls this directly

Calls 4

decompressFunction · 0.90
assertRaisesRegexMethod · 0.80
copyMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected