(self)
| 23 | # Test error cases. |
| 24 | |
| 25 | def test_simple_bad_args(self): |
| 26 | self.assertRaises(TypeError, LZMACompressor, []) |
| 27 | self.assertRaises(TypeError, LZMACompressor, format=3.45) |
| 28 | self.assertRaises(TypeError, LZMACompressor, check="") |
| 29 | self.assertRaises(TypeError, LZMACompressor, preset="asdf") |
| 30 | self.assertRaises(TypeError, LZMACompressor, filters=3) |
| 31 | # Can't specify FORMAT_AUTO when compressing. |
| 32 | self.assertRaises(ValueError, LZMACompressor, format=lzma.FORMAT_AUTO) |
| 33 | # Can't specify a preset and a custom filter chain at the same time. |
| 34 | with self.assertRaises(ValueError): |
| 35 | LZMACompressor(preset=7, filters=[{"id": lzma.FILTER_LZMA2}]) |
| 36 | |
| 37 | self.assertRaises(TypeError, LZMADecompressor, ()) |
| 38 | self.assertRaises(TypeError, LZMADecompressor, memlimit=b"qw") |
| 39 | with self.assertRaises(TypeError): |
| 40 | LZMADecompressor(lzma.FORMAT_RAW, filters="zzz") |
| 41 | # Cannot specify a memory limit with FILTER_RAW. |
| 42 | with self.assertRaises(ValueError): |
| 43 | LZMADecompressor(lzma.FORMAT_RAW, memlimit=0x1000000) |
| 44 | # Can only specify a custom filter chain with FILTER_RAW. |
| 45 | self.assertRaises(ValueError, LZMADecompressor, filters=FILTERS_RAW_1) |
| 46 | with self.assertRaises(ValueError): |
| 47 | LZMADecompressor(format=lzma.FORMAT_XZ, filters=FILTERS_RAW_1) |
| 48 | with self.assertRaises(ValueError): |
| 49 | LZMADecompressor(format=lzma.FORMAT_ALONE, filters=FILTERS_RAW_1) |
| 50 | |
| 51 | lzc = LZMACompressor() |
| 52 | self.assertRaises(TypeError, lzc.compress) |
| 53 | self.assertRaises(TypeError, lzc.compress, b"foo", b"bar") |
| 54 | self.assertRaises(TypeError, lzc.flush, b"blah") |
| 55 | empty = lzc.flush() |
| 56 | self.assertRaises(ValueError, lzc.compress, b"quux") |
| 57 | self.assertRaises(ValueError, lzc.flush) |
| 58 | |
| 59 | lzd = LZMADecompressor() |
| 60 | self.assertRaises(TypeError, lzd.decompress) |
| 61 | self.assertRaises(TypeError, lzd.decompress, b"foo", b"bar") |
| 62 | lzd.decompress(empty) |
| 63 | self.assertRaises(EOFError, lzd.decompress, b"quux") |
| 64 | |
| 65 | def test_bad_filter_spec(self): |
| 66 | self.assertRaises(TypeError, LZMACompressor, filters=[b"wobsite"]) |
nothing calls this directly
no test coverage detected