def test__encode_filter_properties(self):
with self.assertRaises(TypeError):
lzma._encode_filter_properties(b"not a dict")
with self.assertRaises(ValueError):
lzma._encode_filter_properties({"id": 0x100})
with self.assertRaises(ValueError):
lzma._encode_filter_properties({"id": lzma.FILTER_LZMA2, "junk": 12})
with self.assertRaises(lzma.LZMAError):
lzma._encode_filter_properties({"id": lzma.FILTER_DELTA,
"dist": 9001})
# Test with parameters used by zipfile module.
props = lzma._encode_filter_properties({
"id": lzma.FILTER_LZMA1,
"pb": 2,
"lp": 0,
"lc": 3,
"dict_size": 8 << 20,
})
self.assertEqual(props, b"]\x00\x00\x80\x00")
评论列表
文章目录