blob: db20300056e489975285d5a089f68e858579f469 [file] [log] [blame]
Antoine Pitrou2dbc6e62015-04-11 00:31:01 +02001import _compression
2from io import BytesIO, UnsupportedOperation, DEFAULT_BUFFER_SIZE
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02003import os
Berker Peksag5f59ddd2016-10-04 20:41:20 +03004import pathlib
Nadeem Vawda37970652013-10-28 21:35:23 +01005import pickle
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02006import random
Oren Milmand019bc82018-02-13 12:28:33 +02007import sys
8from test import support
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02009import unittest
10
11from test.support import (
Hai Shi0c4f0f32020-06-30 21:46:31 +080012 _4G, bigmemtest, run_unittest
13)
14from test.support.import_helper import import_module
15from test.support.os_helper import (
16 TESTFN, unlink
Nadeem Vawda3ff069e2011-11-30 00:25:06 +020017)
18
19lzma = import_module("lzma")
20from lzma import LZMACompressor, LZMADecompressor, LZMAError, LZMAFile
21
22
23class CompressorDecompressorTestCase(unittest.TestCase):
24
25 # Test error cases.
26
27 def test_simple_bad_args(self):
28 self.assertRaises(TypeError, LZMACompressor, [])
29 self.assertRaises(TypeError, LZMACompressor, format=3.45)
30 self.assertRaises(TypeError, LZMACompressor, check="")
31 self.assertRaises(TypeError, LZMACompressor, preset="asdf")
32 self.assertRaises(TypeError, LZMACompressor, filters=3)
33 # Can't specify FORMAT_AUTO when compressing.
34 self.assertRaises(ValueError, LZMACompressor, format=lzma.FORMAT_AUTO)
35 # Can't specify a preset and a custom filter chain at the same time.
36 with self.assertRaises(ValueError):
37 LZMACompressor(preset=7, filters=[{"id": lzma.FILTER_LZMA2}])
38
39 self.assertRaises(TypeError, LZMADecompressor, ())
40 self.assertRaises(TypeError, LZMADecompressor, memlimit=b"qw")
41 with self.assertRaises(TypeError):
42 LZMADecompressor(lzma.FORMAT_RAW, filters="zzz")
43 # Cannot specify a memory limit with FILTER_RAW.
44 with self.assertRaises(ValueError):
45 LZMADecompressor(lzma.FORMAT_RAW, memlimit=0x1000000)
46 # Can only specify a custom filter chain with FILTER_RAW.
47 self.assertRaises(ValueError, LZMADecompressor, filters=FILTERS_RAW_1)
48 with self.assertRaises(ValueError):
49 LZMADecompressor(format=lzma.FORMAT_XZ, filters=FILTERS_RAW_1)
50 with self.assertRaises(ValueError):
51 LZMADecompressor(format=lzma.FORMAT_ALONE, filters=FILTERS_RAW_1)
52
53 lzc = LZMACompressor()
54 self.assertRaises(TypeError, lzc.compress)
55 self.assertRaises(TypeError, lzc.compress, b"foo", b"bar")
56 self.assertRaises(TypeError, lzc.flush, b"blah")
57 empty = lzc.flush()
58 self.assertRaises(ValueError, lzc.compress, b"quux")
59 self.assertRaises(ValueError, lzc.flush)
60
61 lzd = LZMADecompressor()
62 self.assertRaises(TypeError, lzd.decompress)
63 self.assertRaises(TypeError, lzd.decompress, b"foo", b"bar")
64 lzd.decompress(empty)
65 self.assertRaises(EOFError, lzd.decompress, b"quux")
66
67 def test_bad_filter_spec(self):
68 self.assertRaises(TypeError, LZMACompressor, filters=[b"wobsite"])
69 self.assertRaises(ValueError, LZMACompressor, filters=[{"xyzzy": 3}])
70 self.assertRaises(ValueError, LZMACompressor, filters=[{"id": 98765}])
71 with self.assertRaises(ValueError):
72 LZMACompressor(filters=[{"id": lzma.FILTER_LZMA2, "foo": 0}])
73 with self.assertRaises(ValueError):
74 LZMACompressor(filters=[{"id": lzma.FILTER_DELTA, "foo": 0}])
75 with self.assertRaises(ValueError):
76 LZMACompressor(filters=[{"id": lzma.FILTER_X86, "foo": 0}])
77
78 def test_decompressor_after_eof(self):
79 lzd = LZMADecompressor()
80 lzd.decompress(COMPRESSED_XZ)
81 self.assertRaises(EOFError, lzd.decompress, b"nyan")
82
83 def test_decompressor_memlimit(self):
84 lzd = LZMADecompressor(memlimit=1024)
85 self.assertRaises(LZMAError, lzd.decompress, COMPRESSED_XZ)
86
87 lzd = LZMADecompressor(lzma.FORMAT_XZ, memlimit=1024)
88 self.assertRaises(LZMAError, lzd.decompress, COMPRESSED_XZ)
89
90 lzd = LZMADecompressor(lzma.FORMAT_ALONE, memlimit=1024)
91 self.assertRaises(LZMAError, lzd.decompress, COMPRESSED_ALONE)
92
93 # Test LZMADecompressor on known-good input data.
94
95 def _test_decompressor(self, lzd, data, check, unused_data=b""):
96 self.assertFalse(lzd.eof)
97 out = lzd.decompress(data)
98 self.assertEqual(out, INPUT)
99 self.assertEqual(lzd.check, check)
100 self.assertTrue(lzd.eof)
101 self.assertEqual(lzd.unused_data, unused_data)
102
103 def test_decompressor_auto(self):
104 lzd = LZMADecompressor()
105 self._test_decompressor(lzd, COMPRESSED_XZ, lzma.CHECK_CRC64)
106
107 lzd = LZMADecompressor()
108 self._test_decompressor(lzd, COMPRESSED_ALONE, lzma.CHECK_NONE)
109
110 def test_decompressor_xz(self):
111 lzd = LZMADecompressor(lzma.FORMAT_XZ)
112 self._test_decompressor(lzd, COMPRESSED_XZ, lzma.CHECK_CRC64)
113
114 def test_decompressor_alone(self):
115 lzd = LZMADecompressor(lzma.FORMAT_ALONE)
116 self._test_decompressor(lzd, COMPRESSED_ALONE, lzma.CHECK_NONE)
117
118 def test_decompressor_raw_1(self):
119 lzd = LZMADecompressor(lzma.FORMAT_RAW, filters=FILTERS_RAW_1)
120 self._test_decompressor(lzd, COMPRESSED_RAW_1, lzma.CHECK_NONE)
121
122 def test_decompressor_raw_2(self):
123 lzd = LZMADecompressor(lzma.FORMAT_RAW, filters=FILTERS_RAW_2)
124 self._test_decompressor(lzd, COMPRESSED_RAW_2, lzma.CHECK_NONE)
125
126 def test_decompressor_raw_3(self):
127 lzd = LZMADecompressor(lzma.FORMAT_RAW, filters=FILTERS_RAW_3)
128 self._test_decompressor(lzd, COMPRESSED_RAW_3, lzma.CHECK_NONE)
129
130 def test_decompressor_raw_4(self):
131 lzd = LZMADecompressor(lzma.FORMAT_RAW, filters=FILTERS_RAW_4)
132 self._test_decompressor(lzd, COMPRESSED_RAW_4, lzma.CHECK_NONE)
133
134 def test_decompressor_chunks(self):
135 lzd = LZMADecompressor()
136 out = []
137 for i in range(0, len(COMPRESSED_XZ), 10):
138 self.assertFalse(lzd.eof)
139 out.append(lzd.decompress(COMPRESSED_XZ[i:i+10]))
140 out = b"".join(out)
141 self.assertEqual(out, INPUT)
142 self.assertEqual(lzd.check, lzma.CHECK_CRC64)
143 self.assertTrue(lzd.eof)
144 self.assertEqual(lzd.unused_data, b"")
145
Serhiy Storchaka04f17f12016-10-31 08:30:09 +0200146 def test_decompressor_chunks_empty(self):
147 lzd = LZMADecompressor()
148 out = []
149 for i in range(0, len(COMPRESSED_XZ), 10):
150 self.assertFalse(lzd.eof)
151 out.append(lzd.decompress(b''))
152 out.append(lzd.decompress(b''))
153 out.append(lzd.decompress(b''))
154 out.append(lzd.decompress(COMPRESSED_XZ[i:i+10]))
155 out = b"".join(out)
156 self.assertEqual(out, INPUT)
157 self.assertEqual(lzd.check, lzma.CHECK_CRC64)
158 self.assertTrue(lzd.eof)
159 self.assertEqual(lzd.unused_data, b"")
160
Antoine Pitrou26795ba2015-01-17 16:22:18 +0100161 def test_decompressor_chunks_maxsize(self):
162 lzd = LZMADecompressor()
163 max_length = 100
164 out = []
165
166 # Feed first half the input
167 len_ = len(COMPRESSED_XZ) // 2
168 out.append(lzd.decompress(COMPRESSED_XZ[:len_],
169 max_length=max_length))
170 self.assertFalse(lzd.needs_input)
171 self.assertEqual(len(out[-1]), max_length)
172
173 # Retrieve more data without providing more input
174 out.append(lzd.decompress(b'', max_length=max_length))
175 self.assertFalse(lzd.needs_input)
176 self.assertEqual(len(out[-1]), max_length)
177
178 # Retrieve more data while providing more input
179 out.append(lzd.decompress(COMPRESSED_XZ[len_:],
180 max_length=max_length))
181 self.assertLessEqual(len(out[-1]), max_length)
182
183 # Retrieve remaining uncompressed data
184 while not lzd.eof:
185 out.append(lzd.decompress(b'', max_length=max_length))
186 self.assertLessEqual(len(out[-1]), max_length)
187
188 out = b"".join(out)
189 self.assertEqual(out, INPUT)
190 self.assertEqual(lzd.check, lzma.CHECK_CRC64)
191 self.assertEqual(lzd.unused_data, b"")
192
193 def test_decompressor_inputbuf_1(self):
194 # Test reusing input buffer after moving existing
195 # contents to beginning
196 lzd = LZMADecompressor()
197 out = []
198
199 # Create input buffer and fill it
200 self.assertEqual(lzd.decompress(COMPRESSED_XZ[:100],
201 max_length=0), b'')
202
203 # Retrieve some results, freeing capacity at beginning
204 # of input buffer
205 out.append(lzd.decompress(b'', 2))
206
207 # Add more data that fits into input buffer after
208 # moving existing data to beginning
209 out.append(lzd.decompress(COMPRESSED_XZ[100:105], 15))
210
211 # Decompress rest of data
212 out.append(lzd.decompress(COMPRESSED_XZ[105:]))
213 self.assertEqual(b''.join(out), INPUT)
214
215 def test_decompressor_inputbuf_2(self):
216 # Test reusing input buffer by appending data at the
217 # end right away
218 lzd = LZMADecompressor()
219 out = []
220
221 # Create input buffer and empty it
222 self.assertEqual(lzd.decompress(COMPRESSED_XZ[:200],
223 max_length=0), b'')
224 out.append(lzd.decompress(b''))
225
226 # Fill buffer with new data
227 out.append(lzd.decompress(COMPRESSED_XZ[200:280], 2))
228
229 # Append some more data, not enough to require resize
230 out.append(lzd.decompress(COMPRESSED_XZ[280:300], 2))
231
232 # Decompress rest of data
233 out.append(lzd.decompress(COMPRESSED_XZ[300:]))
234 self.assertEqual(b''.join(out), INPUT)
235
236 def test_decompressor_inputbuf_3(self):
237 # Test reusing input buffer after extending it
238
239 lzd = LZMADecompressor()
240 out = []
241
242 # Create almost full input buffer
243 out.append(lzd.decompress(COMPRESSED_XZ[:200], 5))
244
245 # Add even more data to it, requiring resize
246 out.append(lzd.decompress(COMPRESSED_XZ[200:300], 5))
247
248 # Decompress rest of data
249 out.append(lzd.decompress(COMPRESSED_XZ[300:]))
250 self.assertEqual(b''.join(out), INPUT)
251
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200252 def test_decompressor_unused_data(self):
253 lzd = LZMADecompressor()
254 extra = b"fooblibar"
255 self._test_decompressor(lzd, COMPRESSED_XZ + extra, lzma.CHECK_CRC64,
256 unused_data=extra)
257
258 def test_decompressor_bad_input(self):
259 lzd = LZMADecompressor()
260 self.assertRaises(LZMAError, lzd.decompress, COMPRESSED_RAW_1)
261
262 lzd = LZMADecompressor(lzma.FORMAT_XZ)
263 self.assertRaises(LZMAError, lzd.decompress, COMPRESSED_ALONE)
264
265 lzd = LZMADecompressor(lzma.FORMAT_ALONE)
266 self.assertRaises(LZMAError, lzd.decompress, COMPRESSED_XZ)
267
268 lzd = LZMADecompressor(lzma.FORMAT_RAW, filters=FILTERS_RAW_1)
269 self.assertRaises(LZMAError, lzd.decompress, COMPRESSED_XZ)
270
Serhiy Storchakac0b70372016-09-27 20:14:26 +0300271 def test_decompressor_bug_28275(self):
272 # Test coverage for Issue 28275
273 lzd = LZMADecompressor()
Martin Panter38317d32016-10-01 02:45:17 +0000274 self.assertRaises(LZMAError, lzd.decompress, COMPRESSED_RAW_1)
275 # Previously, a second call could crash due to internal inconsistency
276 self.assertRaises(LZMAError, lzd.decompress, COMPRESSED_RAW_1)
Serhiy Storchakac0b70372016-09-27 20:14:26 +0300277
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200278 # Test that LZMACompressor->LZMADecompressor preserves the input data.
279
280 def test_roundtrip_xz(self):
281 lzc = LZMACompressor()
282 cdata = lzc.compress(INPUT) + lzc.flush()
283 lzd = LZMADecompressor()
284 self._test_decompressor(lzd, cdata, lzma.CHECK_CRC64)
285
286 def test_roundtrip_alone(self):
287 lzc = LZMACompressor(lzma.FORMAT_ALONE)
288 cdata = lzc.compress(INPUT) + lzc.flush()
289 lzd = LZMADecompressor()
290 self._test_decompressor(lzd, cdata, lzma.CHECK_NONE)
291
292 def test_roundtrip_raw(self):
293 lzc = LZMACompressor(lzma.FORMAT_RAW, filters=FILTERS_RAW_4)
294 cdata = lzc.compress(INPUT) + lzc.flush()
295 lzd = LZMADecompressor(lzma.FORMAT_RAW, filters=FILTERS_RAW_4)
296 self._test_decompressor(lzd, cdata, lzma.CHECK_NONE)
297
Serhiy Storchaka04f17f12016-10-31 08:30:09 +0200298 def test_roundtrip_raw_empty(self):
299 lzc = LZMACompressor(lzma.FORMAT_RAW, filters=FILTERS_RAW_4)
300 cdata = lzc.compress(INPUT)
301 cdata += lzc.compress(b'')
302 cdata += lzc.compress(b'')
303 cdata += lzc.compress(b'')
304 cdata += lzc.flush()
305 lzd = LZMADecompressor(lzma.FORMAT_RAW, filters=FILTERS_RAW_4)
306 self._test_decompressor(lzd, cdata, lzma.CHECK_NONE)
307
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200308 def test_roundtrip_chunks(self):
309 lzc = LZMACompressor()
310 cdata = []
311 for i in range(0, len(INPUT), 10):
312 cdata.append(lzc.compress(INPUT[i:i+10]))
313 cdata.append(lzc.flush())
314 cdata = b"".join(cdata)
315 lzd = LZMADecompressor()
316 self._test_decompressor(lzd, cdata, lzma.CHECK_CRC64)
317
Serhiy Storchaka04f17f12016-10-31 08:30:09 +0200318 def test_roundtrip_empty_chunks(self):
319 lzc = LZMACompressor()
320 cdata = []
321 for i in range(0, len(INPUT), 10):
322 cdata.append(lzc.compress(INPUT[i:i+10]))
323 cdata.append(lzc.compress(b''))
324 cdata.append(lzc.compress(b''))
325 cdata.append(lzc.compress(b''))
326 cdata.append(lzc.flush())
327 cdata = b"".join(cdata)
328 lzd = LZMADecompressor()
329 self._test_decompressor(lzd, cdata, lzma.CHECK_CRC64)
330
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200331 # LZMADecompressor intentionally does not handle concatenated streams.
332
333 def test_decompressor_multistream(self):
334 lzd = LZMADecompressor()
335 self._test_decompressor(lzd, COMPRESSED_XZ + COMPRESSED_ALONE,
336 lzma.CHECK_CRC64, unused_data=COMPRESSED_ALONE)
337
338 # Test with inputs larger than 4GiB.
339
Neil Schemenauer52a48e62019-07-30 11:08:18 -0700340 @support.skip_if_pgo_task
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200341 @bigmemtest(size=_4G + 100, memuse=2)
342 def test_compressor_bigmem(self, size):
343 lzc = LZMACompressor()
344 cdata = lzc.compress(b"x" * size) + lzc.flush()
345 ddata = lzma.decompress(cdata)
346 try:
347 self.assertEqual(len(ddata), size)
348 self.assertEqual(len(ddata.strip(b"x")), 0)
349 finally:
350 ddata = None
351
Neil Schemenauer52a48e62019-07-30 11:08:18 -0700352 @support.skip_if_pgo_task
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200353 @bigmemtest(size=_4G + 100, memuse=3)
354 def test_decompressor_bigmem(self, size):
355 lzd = LZMADecompressor()
356 blocksize = 10 * 1024 * 1024
Victor Stinner87502dd2020-04-17 22:54:38 +0200357 block = random.randbytes(blocksize)
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200358 try:
359 input = block * (size // blocksize + 1)
360 cdata = lzma.compress(input)
361 ddata = lzd.decompress(cdata)
362 self.assertEqual(ddata, input)
363 finally:
364 input = cdata = ddata = None
365
Nadeem Vawda37970652013-10-28 21:35:23 +0100366 # Pickling raises an exception; there's no way to serialize an lzma_stream.
367
368 def test_pickle(self):
Serhiy Storchakabad12572014-12-15 14:03:42 +0200369 for proto in range(pickle.HIGHEST_PROTOCOL + 1):
370 with self.assertRaises(TypeError):
371 pickle.dumps(LZMACompressor(), proto)
372 with self.assertRaises(TypeError):
373 pickle.dumps(LZMADecompressor(), proto)
Nadeem Vawda37970652013-10-28 21:35:23 +0100374
Oren Milmand019bc82018-02-13 12:28:33 +0200375 @support.refcount_test
376 def test_refleaks_in_decompressor___init__(self):
377 gettotalrefcount = support.get_attribute(sys, 'gettotalrefcount')
378 lzd = LZMADecompressor()
379 refs_before = gettotalrefcount()
380 for i in range(100):
381 lzd.__init__()
382 self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10)
383
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200384
385class CompressDecompressFunctionTestCase(unittest.TestCase):
386
387 # Test error cases:
388
389 def test_bad_args(self):
390 self.assertRaises(TypeError, lzma.compress)
391 self.assertRaises(TypeError, lzma.compress, [])
392 self.assertRaises(TypeError, lzma.compress, b"", format="xz")
393 self.assertRaises(TypeError, lzma.compress, b"", check="none")
394 self.assertRaises(TypeError, lzma.compress, b"", preset="blah")
395 self.assertRaises(TypeError, lzma.compress, b"", filters=1024)
396 # Can't specify a preset and a custom filter chain at the same time.
397 with self.assertRaises(ValueError):
398 lzma.compress(b"", preset=3, filters=[{"id": lzma.FILTER_LZMA2}])
399
400 self.assertRaises(TypeError, lzma.decompress)
401 self.assertRaises(TypeError, lzma.decompress, [])
402 self.assertRaises(TypeError, lzma.decompress, b"", format="lzma")
403 self.assertRaises(TypeError, lzma.decompress, b"", memlimit=7.3e9)
404 with self.assertRaises(TypeError):
405 lzma.decompress(b"", format=lzma.FORMAT_RAW, filters={})
406 # Cannot specify a memory limit with FILTER_RAW.
407 with self.assertRaises(ValueError):
408 lzma.decompress(b"", format=lzma.FORMAT_RAW, memlimit=0x1000000)
409 # Can only specify a custom filter chain with FILTER_RAW.
410 with self.assertRaises(ValueError):
411 lzma.decompress(b"", filters=FILTERS_RAW_1)
412 with self.assertRaises(ValueError):
413 lzma.decompress(b"", format=lzma.FORMAT_XZ, filters=FILTERS_RAW_1)
414 with self.assertRaises(ValueError):
415 lzma.decompress(
416 b"", format=lzma.FORMAT_ALONE, filters=FILTERS_RAW_1)
417
418 def test_decompress_memlimit(self):
419 with self.assertRaises(LZMAError):
420 lzma.decompress(COMPRESSED_XZ, memlimit=1024)
421 with self.assertRaises(LZMAError):
422 lzma.decompress(
423 COMPRESSED_XZ, format=lzma.FORMAT_XZ, memlimit=1024)
424 with self.assertRaises(LZMAError):
425 lzma.decompress(
426 COMPRESSED_ALONE, format=lzma.FORMAT_ALONE, memlimit=1024)
427
428 # Test LZMADecompressor on known-good input data.
429
430 def test_decompress_good_input(self):
431 ddata = lzma.decompress(COMPRESSED_XZ)
432 self.assertEqual(ddata, INPUT)
433
434 ddata = lzma.decompress(COMPRESSED_ALONE)
435 self.assertEqual(ddata, INPUT)
436
437 ddata = lzma.decompress(COMPRESSED_XZ, lzma.FORMAT_XZ)
438 self.assertEqual(ddata, INPUT)
439
440 ddata = lzma.decompress(COMPRESSED_ALONE, lzma.FORMAT_ALONE)
441 self.assertEqual(ddata, INPUT)
442
443 ddata = lzma.decompress(
444 COMPRESSED_RAW_1, lzma.FORMAT_RAW, filters=FILTERS_RAW_1)
445 self.assertEqual(ddata, INPUT)
446
447 ddata = lzma.decompress(
448 COMPRESSED_RAW_2, lzma.FORMAT_RAW, filters=FILTERS_RAW_2)
449 self.assertEqual(ddata, INPUT)
450
451 ddata = lzma.decompress(
452 COMPRESSED_RAW_3, lzma.FORMAT_RAW, filters=FILTERS_RAW_3)
453 self.assertEqual(ddata, INPUT)
454
455 ddata = lzma.decompress(
456 COMPRESSED_RAW_4, lzma.FORMAT_RAW, filters=FILTERS_RAW_4)
457 self.assertEqual(ddata, INPUT)
458
459 def test_decompress_incomplete_input(self):
460 self.assertRaises(LZMAError, lzma.decompress, COMPRESSED_XZ[:128])
461 self.assertRaises(LZMAError, lzma.decompress, COMPRESSED_ALONE[:128])
462 self.assertRaises(LZMAError, lzma.decompress, COMPRESSED_RAW_1[:128],
463 format=lzma.FORMAT_RAW, filters=FILTERS_RAW_1)
464 self.assertRaises(LZMAError, lzma.decompress, COMPRESSED_RAW_2[:128],
465 format=lzma.FORMAT_RAW, filters=FILTERS_RAW_2)
466 self.assertRaises(LZMAError, lzma.decompress, COMPRESSED_RAW_3[:128],
467 format=lzma.FORMAT_RAW, filters=FILTERS_RAW_3)
468 self.assertRaises(LZMAError, lzma.decompress, COMPRESSED_RAW_4[:128],
469 format=lzma.FORMAT_RAW, filters=FILTERS_RAW_4)
470
471 def test_decompress_bad_input(self):
472 with self.assertRaises(LZMAError):
Nadeem Vawda9c72ebc2013-12-04 23:03:49 +0100473 lzma.decompress(COMPRESSED_BOGUS)
474 with self.assertRaises(LZMAError):
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200475 lzma.decompress(COMPRESSED_RAW_1)
476 with self.assertRaises(LZMAError):
477 lzma.decompress(COMPRESSED_ALONE, format=lzma.FORMAT_XZ)
478 with self.assertRaises(LZMAError):
479 lzma.decompress(COMPRESSED_XZ, format=lzma.FORMAT_ALONE)
480 with self.assertRaises(LZMAError):
481 lzma.decompress(COMPRESSED_XZ, format=lzma.FORMAT_RAW,
482 filters=FILTERS_RAW_1)
483
484 # Test that compress()->decompress() preserves the input data.
485
486 def test_roundtrip(self):
487 cdata = lzma.compress(INPUT)
488 ddata = lzma.decompress(cdata)
489 self.assertEqual(ddata, INPUT)
490
491 cdata = lzma.compress(INPUT, lzma.FORMAT_XZ)
492 ddata = lzma.decompress(cdata)
493 self.assertEqual(ddata, INPUT)
494
495 cdata = lzma.compress(INPUT, lzma.FORMAT_ALONE)
496 ddata = lzma.decompress(cdata)
497 self.assertEqual(ddata, INPUT)
498
499 cdata = lzma.compress(INPUT, lzma.FORMAT_RAW, filters=FILTERS_RAW_4)
500 ddata = lzma.decompress(cdata, lzma.FORMAT_RAW, filters=FILTERS_RAW_4)
501 self.assertEqual(ddata, INPUT)
502
503 # Unlike LZMADecompressor, decompress() *does* handle concatenated streams.
504
505 def test_decompress_multistream(self):
506 ddata = lzma.decompress(COMPRESSED_XZ + COMPRESSED_ALONE)
507 self.assertEqual(ddata, INPUT * 2)
508
Nadeem Vawda9c72ebc2013-12-04 23:03:49 +0100509 # Test robust handling of non-LZMA data following the compressed stream(s).
510
511 def test_decompress_trailing_junk(self):
512 ddata = lzma.decompress(COMPRESSED_XZ + COMPRESSED_BOGUS)
513 self.assertEqual(ddata, INPUT)
514
515 def test_decompress_multistream_trailing_junk(self):
516 ddata = lzma.decompress(COMPRESSED_XZ * 3 + COMPRESSED_BOGUS)
517 self.assertEqual(ddata, INPUT * 3)
518
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200519
520class TempFile:
521 """Context manager - creates a file, and deletes it on __exit__."""
522
523 def __init__(self, filename, data=b""):
524 self.filename = filename
525 self.data = data
526
527 def __enter__(self):
528 with open(self.filename, "wb") as f:
529 f.write(self.data)
530
531 def __exit__(self, *args):
532 unlink(self.filename)
533
534
535class FileTestCase(unittest.TestCase):
536
537 def test_init(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200538 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200539 pass
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200540 with LZMAFile(BytesIO(), "w") as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200541 pass
Nadeem Vawda42ca9822013-10-19 00:06:19 +0200542 with LZMAFile(BytesIO(), "x") as f:
543 pass
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200544 with LZMAFile(BytesIO(), "a") as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200545 pass
546
Berker Peksag5f59ddd2016-10-04 20:41:20 +0300547 def test_init_with_PathLike_filename(self):
548 filename = pathlib.Path(TESTFN)
549 with TempFile(filename, COMPRESSED_XZ):
550 with LZMAFile(filename) as f:
551 self.assertEqual(f.read(), INPUT)
552 with LZMAFile(filename, "a") as f:
553 f.write(INPUT)
554 with LZMAFile(filename) as f:
555 self.assertEqual(f.read(), INPUT * 2)
556
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200557 def test_init_with_filename(self):
558 with TempFile(TESTFN, COMPRESSED_XZ):
559 with LZMAFile(TESTFN) as f:
560 pass
561 with LZMAFile(TESTFN, "w") as f:
562 pass
563 with LZMAFile(TESTFN, "a") as f:
564 pass
565
Nadeem Vawda6cbb20c2012-06-04 23:36:24 +0200566 def test_init_mode(self):
567 with TempFile(TESTFN):
568 with LZMAFile(TESTFN, "r"):
569 pass
570 with LZMAFile(TESTFN, "rb"):
571 pass
572 with LZMAFile(TESTFN, "w"):
573 pass
574 with LZMAFile(TESTFN, "wb"):
575 pass
576 with LZMAFile(TESTFN, "a"):
577 pass
578 with LZMAFile(TESTFN, "ab"):
579 pass
580
Nadeem Vawda42ca9822013-10-19 00:06:19 +0200581 def test_init_with_x_mode(self):
582 self.addCleanup(unlink, TESTFN)
583 for mode in ("x", "xb"):
584 unlink(TESTFN)
585 with LZMAFile(TESTFN, mode):
586 pass
587 with self.assertRaises(FileExistsError):
588 with LZMAFile(TESTFN, mode):
589 pass
590
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200591 def test_init_bad_mode(self):
592 with self.assertRaises(ValueError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200593 LZMAFile(BytesIO(COMPRESSED_XZ), (3, "x"))
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200594 with self.assertRaises(ValueError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200595 LZMAFile(BytesIO(COMPRESSED_XZ), "")
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200596 with self.assertRaises(ValueError):
Nadeem Vawda42ca9822013-10-19 00:06:19 +0200597 LZMAFile(BytesIO(COMPRESSED_XZ), "xt")
598 with self.assertRaises(ValueError):
599 LZMAFile(BytesIO(COMPRESSED_XZ), "x+")
600 with self.assertRaises(ValueError):
601 LZMAFile(BytesIO(COMPRESSED_XZ), "rx")
602 with self.assertRaises(ValueError):
603 LZMAFile(BytesIO(COMPRESSED_XZ), "wx")
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200604 with self.assertRaises(ValueError):
Nadeem Vawda6cbb20c2012-06-04 23:36:24 +0200605 LZMAFile(BytesIO(COMPRESSED_XZ), "rt")
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200606 with self.assertRaises(ValueError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200607 LZMAFile(BytesIO(COMPRESSED_XZ), "r+")
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200608 with self.assertRaises(ValueError):
Nadeem Vawda6cbb20c2012-06-04 23:36:24 +0200609 LZMAFile(BytesIO(COMPRESSED_XZ), "wt")
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200610 with self.assertRaises(ValueError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200611 LZMAFile(BytesIO(COMPRESSED_XZ), "w+")
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200612 with self.assertRaises(ValueError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200613 LZMAFile(BytesIO(COMPRESSED_XZ), "rw")
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200614
615 def test_init_bad_check(self):
616 with self.assertRaises(TypeError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200617 LZMAFile(BytesIO(), "w", check=b"asd")
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200618 # CHECK_UNKNOWN and anything above CHECK_ID_MAX should be invalid.
619 with self.assertRaises(LZMAError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200620 LZMAFile(BytesIO(), "w", check=lzma.CHECK_UNKNOWN)
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200621 with self.assertRaises(LZMAError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200622 LZMAFile(BytesIO(), "w", check=lzma.CHECK_ID_MAX + 3)
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200623 # Cannot specify a check with mode="r".
624 with self.assertRaises(ValueError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200625 LZMAFile(BytesIO(COMPRESSED_XZ), check=lzma.CHECK_NONE)
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200626 with self.assertRaises(ValueError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200627 LZMAFile(BytesIO(COMPRESSED_XZ), check=lzma.CHECK_CRC32)
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200628 with self.assertRaises(ValueError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200629 LZMAFile(BytesIO(COMPRESSED_XZ), check=lzma.CHECK_CRC64)
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200630 with self.assertRaises(ValueError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200631 LZMAFile(BytesIO(COMPRESSED_XZ), check=lzma.CHECK_SHA256)
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200632 with self.assertRaises(ValueError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200633 LZMAFile(BytesIO(COMPRESSED_XZ), check=lzma.CHECK_UNKNOWN)
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200634
635 def test_init_bad_preset(self):
636 with self.assertRaises(TypeError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200637 LZMAFile(BytesIO(), "w", preset=4.39)
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200638 with self.assertRaises(LZMAError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200639 LZMAFile(BytesIO(), "w", preset=10)
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200640 with self.assertRaises(LZMAError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200641 LZMAFile(BytesIO(), "w", preset=23)
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200642 with self.assertRaises(OverflowError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200643 LZMAFile(BytesIO(), "w", preset=-1)
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200644 with self.assertRaises(OverflowError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200645 LZMAFile(BytesIO(), "w", preset=-7)
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200646 with self.assertRaises(TypeError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200647 LZMAFile(BytesIO(), "w", preset="foo")
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200648 # Cannot specify a preset with mode="r".
649 with self.assertRaises(ValueError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200650 LZMAFile(BytesIO(COMPRESSED_XZ), preset=3)
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200651
652 def test_init_bad_filter_spec(self):
653 with self.assertRaises(TypeError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200654 LZMAFile(BytesIO(), "w", filters=[b"wobsite"])
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200655 with self.assertRaises(ValueError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200656 LZMAFile(BytesIO(), "w", filters=[{"xyzzy": 3}])
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200657 with self.assertRaises(ValueError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200658 LZMAFile(BytesIO(), "w", filters=[{"id": 98765}])
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200659 with self.assertRaises(ValueError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200660 LZMAFile(BytesIO(), "w",
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200661 filters=[{"id": lzma.FILTER_LZMA2, "foo": 0}])
662 with self.assertRaises(ValueError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200663 LZMAFile(BytesIO(), "w",
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200664 filters=[{"id": lzma.FILTER_DELTA, "foo": 0}])
665 with self.assertRaises(ValueError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200666 LZMAFile(BytesIO(), "w",
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200667 filters=[{"id": lzma.FILTER_X86, "foo": 0}])
668
669 def test_init_with_preset_and_filters(self):
670 with self.assertRaises(ValueError):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200671 LZMAFile(BytesIO(), "w", format=lzma.FORMAT_RAW,
672 preset=6, filters=FILTERS_RAW_1)
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200673
674 def test_close(self):
675 with BytesIO(COMPRESSED_XZ) as src:
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200676 f = LZMAFile(src)
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200677 f.close()
678 # LZMAFile.close() should not close the underlying file object.
679 self.assertFalse(src.closed)
680 # Try closing an already-closed LZMAFile.
681 f.close()
682 self.assertFalse(src.closed)
683
684 # Test with a real file on disk, opened directly by LZMAFile.
685 with TempFile(TESTFN, COMPRESSED_XZ):
686 f = LZMAFile(TESTFN)
687 fp = f._fp
688 f.close()
689 # Here, LZMAFile.close() *should* close the underlying file object.
690 self.assertTrue(fp.closed)
691 # Try closing an already-closed LZMAFile.
692 f.close()
693
694 def test_closed(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200695 f = LZMAFile(BytesIO(COMPRESSED_XZ))
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200696 try:
697 self.assertFalse(f.closed)
698 f.read()
699 self.assertFalse(f.closed)
700 finally:
701 f.close()
702 self.assertTrue(f.closed)
703
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200704 f = LZMAFile(BytesIO(), "w")
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200705 try:
706 self.assertFalse(f.closed)
707 finally:
708 f.close()
709 self.assertTrue(f.closed)
710
711 def test_fileno(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200712 f = LZMAFile(BytesIO(COMPRESSED_XZ))
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200713 try:
714 self.assertRaises(UnsupportedOperation, f.fileno)
715 finally:
716 f.close()
717 self.assertRaises(ValueError, f.fileno)
718 with TempFile(TESTFN, COMPRESSED_XZ):
719 f = LZMAFile(TESTFN)
720 try:
721 self.assertEqual(f.fileno(), f._fp.fileno())
722 self.assertIsInstance(f.fileno(), int)
723 finally:
724 f.close()
725 self.assertRaises(ValueError, f.fileno)
726
727 def test_seekable(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200728 f = LZMAFile(BytesIO(COMPRESSED_XZ))
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200729 try:
730 self.assertTrue(f.seekable())
731 f.read()
732 self.assertTrue(f.seekable())
733 finally:
734 f.close()
735 self.assertRaises(ValueError, f.seekable)
736
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200737 f = LZMAFile(BytesIO(), "w")
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200738 try:
739 self.assertFalse(f.seekable())
740 finally:
741 f.close()
742 self.assertRaises(ValueError, f.seekable)
743
Nadeem Vawdaae557d72012-02-12 01:51:38 +0200744 src = BytesIO(COMPRESSED_XZ)
745 src.seekable = lambda: False
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200746 f = LZMAFile(src)
Nadeem Vawdaae557d72012-02-12 01:51:38 +0200747 try:
748 self.assertFalse(f.seekable())
749 finally:
750 f.close()
751 self.assertRaises(ValueError, f.seekable)
752
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200753 def test_readable(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200754 f = LZMAFile(BytesIO(COMPRESSED_XZ))
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200755 try:
756 self.assertTrue(f.readable())
757 f.read()
758 self.assertTrue(f.readable())
759 finally:
760 f.close()
761 self.assertRaises(ValueError, f.readable)
762
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200763 f = LZMAFile(BytesIO(), "w")
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200764 try:
765 self.assertFalse(f.readable())
766 finally:
767 f.close()
768 self.assertRaises(ValueError, f.readable)
769
770 def test_writable(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200771 f = LZMAFile(BytesIO(COMPRESSED_XZ))
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200772 try:
773 self.assertFalse(f.writable())
774 f.read()
775 self.assertFalse(f.writable())
776 finally:
777 f.close()
778 self.assertRaises(ValueError, f.writable)
779
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200780 f = LZMAFile(BytesIO(), "w")
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200781 try:
782 self.assertTrue(f.writable())
783 finally:
784 f.close()
785 self.assertRaises(ValueError, f.writable)
786
787 def test_read(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200788 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200789 self.assertEqual(f.read(), INPUT)
790 self.assertEqual(f.read(), b"")
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200791 with LZMAFile(BytesIO(COMPRESSED_ALONE)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200792 self.assertEqual(f.read(), INPUT)
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200793 with LZMAFile(BytesIO(COMPRESSED_XZ), format=lzma.FORMAT_XZ) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200794 self.assertEqual(f.read(), INPUT)
795 self.assertEqual(f.read(), b"")
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200796 with LZMAFile(BytesIO(COMPRESSED_ALONE), format=lzma.FORMAT_ALONE) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200797 self.assertEqual(f.read(), INPUT)
798 self.assertEqual(f.read(), b"")
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200799 with LZMAFile(BytesIO(COMPRESSED_RAW_1),
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200800 format=lzma.FORMAT_RAW, filters=FILTERS_RAW_1) as f:
801 self.assertEqual(f.read(), INPUT)
802 self.assertEqual(f.read(), b"")
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200803 with LZMAFile(BytesIO(COMPRESSED_RAW_2),
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200804 format=lzma.FORMAT_RAW, filters=FILTERS_RAW_2) as f:
805 self.assertEqual(f.read(), INPUT)
806 self.assertEqual(f.read(), b"")
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200807 with LZMAFile(BytesIO(COMPRESSED_RAW_3),
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200808 format=lzma.FORMAT_RAW, filters=FILTERS_RAW_3) as f:
809 self.assertEqual(f.read(), INPUT)
810 self.assertEqual(f.read(), b"")
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200811 with LZMAFile(BytesIO(COMPRESSED_RAW_4),
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200812 format=lzma.FORMAT_RAW, filters=FILTERS_RAW_4) as f:
813 self.assertEqual(f.read(), INPUT)
814 self.assertEqual(f.read(), b"")
815
816 def test_read_0(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200817 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200818 self.assertEqual(f.read(0), b"")
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200819 with LZMAFile(BytesIO(COMPRESSED_ALONE)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200820 self.assertEqual(f.read(0), b"")
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200821 with LZMAFile(BytesIO(COMPRESSED_XZ), format=lzma.FORMAT_XZ) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200822 self.assertEqual(f.read(0), b"")
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200823 with LZMAFile(BytesIO(COMPRESSED_ALONE), format=lzma.FORMAT_ALONE) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200824 self.assertEqual(f.read(0), b"")
825
826 def test_read_10(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200827 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200828 chunks = []
829 while True:
830 result = f.read(10)
831 if not result:
832 break
833 self.assertLessEqual(len(result), 10)
834 chunks.append(result)
835 self.assertEqual(b"".join(chunks), INPUT)
836
837 def test_read_multistream(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200838 with LZMAFile(BytesIO(COMPRESSED_XZ * 5)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200839 self.assertEqual(f.read(), INPUT * 5)
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200840 with LZMAFile(BytesIO(COMPRESSED_XZ + COMPRESSED_ALONE)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200841 self.assertEqual(f.read(), INPUT * 2)
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200842 with LZMAFile(BytesIO(COMPRESSED_RAW_3 * 4),
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200843 format=lzma.FORMAT_RAW, filters=FILTERS_RAW_3) as f:
844 self.assertEqual(f.read(), INPUT * 4)
845
846 def test_read_multistream_buffer_size_aligned(self):
847 # Test the case where a stream boundary coincides with the end
848 # of the raw read buffer.
Antoine Pitrou2dbc6e62015-04-11 00:31:01 +0200849 saved_buffer_size = _compression.BUFFER_SIZE
850 _compression.BUFFER_SIZE = len(COMPRESSED_XZ)
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200851 try:
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200852 with LZMAFile(BytesIO(COMPRESSED_XZ * 5)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200853 self.assertEqual(f.read(), INPUT * 5)
854 finally:
Antoine Pitrou2dbc6e62015-04-11 00:31:01 +0200855 _compression.BUFFER_SIZE = saved_buffer_size
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200856
Nadeem Vawda9c72ebc2013-12-04 23:03:49 +0100857 def test_read_trailing_junk(self):
858 with LZMAFile(BytesIO(COMPRESSED_XZ + COMPRESSED_BOGUS)) as f:
859 self.assertEqual(f.read(), INPUT)
860
861 def test_read_multistream_trailing_junk(self):
862 with LZMAFile(BytesIO(COMPRESSED_XZ * 5 + COMPRESSED_BOGUS)) as f:
863 self.assertEqual(f.read(), INPUT * 5)
864
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200865 def test_read_from_file(self):
866 with TempFile(TESTFN, COMPRESSED_XZ):
867 with LZMAFile(TESTFN) as f:
868 self.assertEqual(f.read(), INPUT)
869 self.assertEqual(f.read(), b"")
870
Nadeem Vawda10c87912012-06-20 01:48:50 +0200871 def test_read_from_file_with_bytes_filename(self):
872 try:
873 bytes_filename = TESTFN.encode("ascii")
874 except UnicodeEncodeError:
875 self.skipTest("Temporary file name needs to be ASCII")
876 with TempFile(TESTFN, COMPRESSED_XZ):
877 with LZMAFile(bytes_filename) as f:
878 self.assertEqual(f.read(), INPUT)
879 self.assertEqual(f.read(), b"")
880
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200881 def test_read_incomplete(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200882 with LZMAFile(BytesIO(COMPRESSED_XZ[:128])) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200883 self.assertRaises(EOFError, f.read)
884
Serhiy Storchaka57f9b7a2013-01-22 17:07:49 +0200885 def test_read_truncated(self):
886 # Drop stream footer: CRC (4 bytes), index size (4 bytes),
Serhiy Storchaka70ea7fa2013-02-08 11:24:16 +0200887 # flags (2 bytes) and magic number (2 bytes).
Serhiy Storchaka57f9b7a2013-01-22 17:07:49 +0200888 truncated = COMPRESSED_XZ[:-12]
889 with LZMAFile(BytesIO(truncated)) as f:
890 self.assertRaises(EOFError, f.read)
891 with LZMAFile(BytesIO(truncated)) as f:
892 self.assertEqual(f.read(len(INPUT)), INPUT)
893 self.assertRaises(EOFError, f.read, 1)
894 # Incomplete 12-byte header.
895 for i in range(12):
896 with LZMAFile(BytesIO(truncated[:i])) as f:
897 self.assertRaises(EOFError, f.read, 1)
898
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200899 def test_read_bad_args(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200900 f = LZMAFile(BytesIO(COMPRESSED_XZ))
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200901 f.close()
902 self.assertRaises(ValueError, f.read)
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200903 with LZMAFile(BytesIO(), "w") as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200904 self.assertRaises(ValueError, f.read)
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200905 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Antoine Pitrou2dbc6e62015-04-11 00:31:01 +0200906 self.assertRaises(TypeError, f.read, float())
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200907
Nadeem Vawda9c72ebc2013-12-04 23:03:49 +0100908 def test_read_bad_data(self):
909 with LZMAFile(BytesIO(COMPRESSED_BOGUS)) as f:
910 self.assertRaises(LZMAError, f.read)
911
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200912 def test_read1(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200913 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200914 blocks = []
915 while True:
916 result = f.read1()
917 if not result:
918 break
919 blocks.append(result)
920 self.assertEqual(b"".join(blocks), INPUT)
921 self.assertEqual(f.read1(), b"")
922
923 def test_read1_0(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200924 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200925 self.assertEqual(f.read1(0), b"")
926
927 def test_read1_10(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200928 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200929 blocks = []
930 while True:
931 result = f.read1(10)
932 if not result:
933 break
934 blocks.append(result)
935 self.assertEqual(b"".join(blocks), INPUT)
936 self.assertEqual(f.read1(), b"")
937
938 def test_read1_multistream(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200939 with LZMAFile(BytesIO(COMPRESSED_XZ * 5)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200940 blocks = []
941 while True:
942 result = f.read1()
943 if not result:
944 break
945 blocks.append(result)
946 self.assertEqual(b"".join(blocks), INPUT * 5)
947 self.assertEqual(f.read1(), b"")
948
949 def test_read1_bad_args(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200950 f = LZMAFile(BytesIO(COMPRESSED_XZ))
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200951 f.close()
952 self.assertRaises(ValueError, f.read1)
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200953 with LZMAFile(BytesIO(), "w") as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200954 self.assertRaises(ValueError, f.read1)
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200955 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200956 self.assertRaises(TypeError, f.read1, None)
957
958 def test_peek(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200959 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200960 result = f.peek()
961 self.assertGreater(len(result), 0)
962 self.assertTrue(INPUT.startswith(result))
963 self.assertEqual(f.read(), INPUT)
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200964 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200965 result = f.peek(10)
966 self.assertGreater(len(result), 0)
967 self.assertTrue(INPUT.startswith(result))
968 self.assertEqual(f.read(), INPUT)
969
970 def test_peek_bad_args(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200971 with LZMAFile(BytesIO(), "w") as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200972 self.assertRaises(ValueError, f.peek)
973
974 def test_iterator(self):
975 with BytesIO(INPUT) as f:
976 lines = f.readlines()
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200977 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200978 self.assertListEqual(list(iter(f)), lines)
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200979 with LZMAFile(BytesIO(COMPRESSED_ALONE)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200980 self.assertListEqual(list(iter(f)), lines)
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200981 with LZMAFile(BytesIO(COMPRESSED_XZ), format=lzma.FORMAT_XZ) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200982 self.assertListEqual(list(iter(f)), lines)
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200983 with LZMAFile(BytesIO(COMPRESSED_ALONE), format=lzma.FORMAT_ALONE) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200984 self.assertListEqual(list(iter(f)), lines)
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200985 with LZMAFile(BytesIO(COMPRESSED_RAW_2),
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200986 format=lzma.FORMAT_RAW, filters=FILTERS_RAW_2) as f:
987 self.assertListEqual(list(iter(f)), lines)
988
989 def test_readline(self):
990 with BytesIO(INPUT) as f:
991 lines = f.readlines()
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200992 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +0200993 for line in lines:
994 self.assertEqual(f.readline(), line)
995
996 def test_readlines(self):
997 with BytesIO(INPUT) as f:
998 lines = f.readlines()
Nadeem Vawda33c34da2012-06-04 23:34:07 +0200999 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001000 self.assertListEqual(f.readlines(), lines)
1001
Antoine Pitrou2dbc6e62015-04-11 00:31:01 +02001002 def test_decompress_limited(self):
1003 """Decompressed data buffering should be limited"""
Serhiy Storchaka5f1a5182016-09-11 14:41:02 +03001004 bomb = lzma.compress(b'\0' * int(2e6), preset=6)
Antoine Pitrou2dbc6e62015-04-11 00:31:01 +02001005 self.assertLess(len(bomb), _compression.BUFFER_SIZE)
1006
1007 decomp = LZMAFile(BytesIO(bomb))
Serhiy Storchaka5f1a5182016-09-11 14:41:02 +03001008 self.assertEqual(decomp.read(1), b'\0')
Antoine Pitrou2dbc6e62015-04-11 00:31:01 +02001009 max_decomp = 1 + DEFAULT_BUFFER_SIZE
1010 self.assertLessEqual(decomp._buffer.raw.tell(), max_decomp,
1011 "Excessive amount of data was decompressed")
1012
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001013 def test_write(self):
1014 with BytesIO() as dst:
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001015 with LZMAFile(dst, "w") as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001016 f.write(INPUT)
1017 expected = lzma.compress(INPUT)
1018 self.assertEqual(dst.getvalue(), expected)
1019 with BytesIO() as dst:
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001020 with LZMAFile(dst, "w", format=lzma.FORMAT_XZ) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001021 f.write(INPUT)
1022 expected = lzma.compress(INPUT, format=lzma.FORMAT_XZ)
1023 self.assertEqual(dst.getvalue(), expected)
1024 with BytesIO() as dst:
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001025 with LZMAFile(dst, "w", format=lzma.FORMAT_ALONE) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001026 f.write(INPUT)
1027 expected = lzma.compress(INPUT, format=lzma.FORMAT_ALONE)
1028 self.assertEqual(dst.getvalue(), expected)
1029 with BytesIO() as dst:
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001030 with LZMAFile(dst, "w", format=lzma.FORMAT_RAW,
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001031 filters=FILTERS_RAW_2) as f:
1032 f.write(INPUT)
1033 expected = lzma.compress(INPUT, format=lzma.FORMAT_RAW,
1034 filters=FILTERS_RAW_2)
1035 self.assertEqual(dst.getvalue(), expected)
1036
1037 def test_write_10(self):
1038 with BytesIO() as dst:
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001039 with LZMAFile(dst, "w") as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001040 for start in range(0, len(INPUT), 10):
1041 f.write(INPUT[start:start+10])
1042 expected = lzma.compress(INPUT)
1043 self.assertEqual(dst.getvalue(), expected)
1044
1045 def test_write_append(self):
1046 part1 = INPUT[:1024]
1047 part2 = INPUT[1024:1536]
1048 part3 = INPUT[1536:]
1049 expected = b"".join(lzma.compress(x) for x in (part1, part2, part3))
1050 with BytesIO() as dst:
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001051 with LZMAFile(dst, "w") as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001052 f.write(part1)
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001053 with LZMAFile(dst, "a") as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001054 f.write(part2)
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001055 with LZMAFile(dst, "a") as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001056 f.write(part3)
1057 self.assertEqual(dst.getvalue(), expected)
1058
1059 def test_write_to_file(self):
1060 try:
1061 with LZMAFile(TESTFN, "w") as f:
1062 f.write(INPUT)
1063 expected = lzma.compress(INPUT)
1064 with open(TESTFN, "rb") as f:
1065 self.assertEqual(f.read(), expected)
1066 finally:
1067 unlink(TESTFN)
1068
Nadeem Vawda10c87912012-06-20 01:48:50 +02001069 def test_write_to_file_with_bytes_filename(self):
1070 try:
1071 bytes_filename = TESTFN.encode("ascii")
1072 except UnicodeEncodeError:
1073 self.skipTest("Temporary file name needs to be ASCII")
1074 try:
1075 with LZMAFile(bytes_filename, "w") as f:
1076 f.write(INPUT)
1077 expected = lzma.compress(INPUT)
1078 with open(TESTFN, "rb") as f:
1079 self.assertEqual(f.read(), expected)
1080 finally:
1081 unlink(TESTFN)
1082
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001083 def test_write_append_to_file(self):
1084 part1 = INPUT[:1024]
1085 part2 = INPUT[1024:1536]
1086 part3 = INPUT[1536:]
1087 expected = b"".join(lzma.compress(x) for x in (part1, part2, part3))
1088 try:
1089 with LZMAFile(TESTFN, "w") as f:
1090 f.write(part1)
1091 with LZMAFile(TESTFN, "a") as f:
1092 f.write(part2)
1093 with LZMAFile(TESTFN, "a") as f:
1094 f.write(part3)
1095 with open(TESTFN, "rb") as f:
1096 self.assertEqual(f.read(), expected)
1097 finally:
1098 unlink(TESTFN)
1099
1100 def test_write_bad_args(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001101 f = LZMAFile(BytesIO(), "w")
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001102 f.close()
1103 self.assertRaises(ValueError, f.write, b"foo")
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001104 with LZMAFile(BytesIO(COMPRESSED_XZ), "r") as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001105 self.assertRaises(ValueError, f.write, b"bar")
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001106 with LZMAFile(BytesIO(), "w") as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001107 self.assertRaises(TypeError, f.write, None)
1108 self.assertRaises(TypeError, f.write, "text")
1109 self.assertRaises(TypeError, f.write, 789)
1110
1111 def test_writelines(self):
1112 with BytesIO(INPUT) as f:
1113 lines = f.readlines()
1114 with BytesIO() as dst:
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001115 with LZMAFile(dst, "w") as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001116 f.writelines(lines)
1117 expected = lzma.compress(INPUT)
1118 self.assertEqual(dst.getvalue(), expected)
1119
1120 def test_seek_forward(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001121 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001122 f.seek(555)
1123 self.assertEqual(f.read(), INPUT[555:])
1124
1125 def test_seek_forward_across_streams(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001126 with LZMAFile(BytesIO(COMPRESSED_XZ * 2)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001127 f.seek(len(INPUT) + 123)
1128 self.assertEqual(f.read(), INPUT[123:])
1129
1130 def test_seek_forward_relative_to_current(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001131 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001132 f.read(100)
1133 f.seek(1236, 1)
1134 self.assertEqual(f.read(), INPUT[1336:])
1135
1136 def test_seek_forward_relative_to_end(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001137 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001138 f.seek(-555, 2)
1139 self.assertEqual(f.read(), INPUT[-555:])
1140
1141 def test_seek_backward(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001142 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001143 f.read(1001)
1144 f.seek(211)
1145 self.assertEqual(f.read(), INPUT[211:])
1146
1147 def test_seek_backward_across_streams(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001148 with LZMAFile(BytesIO(COMPRESSED_XZ * 2)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001149 f.read(len(INPUT) + 333)
1150 f.seek(737)
1151 self.assertEqual(f.read(), INPUT[737:] + INPUT)
1152
1153 def test_seek_backward_relative_to_end(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001154 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001155 f.seek(-150, 2)
1156 self.assertEqual(f.read(), INPUT[-150:])
1157
1158 def test_seek_past_end(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001159 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001160 f.seek(len(INPUT) + 9001)
1161 self.assertEqual(f.tell(), len(INPUT))
1162 self.assertEqual(f.read(), b"")
1163
1164 def test_seek_past_start(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001165 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001166 f.seek(-88)
1167 self.assertEqual(f.tell(), 0)
1168 self.assertEqual(f.read(), INPUT)
1169
1170 def test_seek_bad_args(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001171 f = LZMAFile(BytesIO(COMPRESSED_XZ))
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001172 f.close()
1173 self.assertRaises(ValueError, f.seek, 0)
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001174 with LZMAFile(BytesIO(), "w") as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001175 self.assertRaises(ValueError, f.seek, 0)
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001176 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001177 self.assertRaises(ValueError, f.seek, 0, 3)
Antoine Pitrou2dbc6e62015-04-11 00:31:01 +02001178 # io.BufferedReader raises TypeError instead of ValueError
1179 self.assertRaises((TypeError, ValueError), f.seek, 9, ())
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001180 self.assertRaises(TypeError, f.seek, None)
1181 self.assertRaises(TypeError, f.seek, b"derp")
1182
1183 def test_tell(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001184 with LZMAFile(BytesIO(COMPRESSED_XZ)) as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001185 pos = 0
1186 while True:
1187 self.assertEqual(f.tell(), pos)
1188 result = f.read(183)
1189 if not result:
1190 break
1191 pos += len(result)
1192 self.assertEqual(f.tell(), len(INPUT))
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001193 with LZMAFile(BytesIO(), "w") as f:
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001194 for pos in range(0, len(INPUT), 144):
1195 self.assertEqual(f.tell(), pos)
1196 f.write(INPUT[pos:pos+144])
1197 self.assertEqual(f.tell(), len(INPUT))
1198
1199 def test_tell_bad_args(self):
Nadeem Vawda33c34da2012-06-04 23:34:07 +02001200 f = LZMAFile(BytesIO(COMPRESSED_XZ))
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001201 f.close()
1202 self.assertRaises(ValueError, f.tell)
1203
animalize4ffd05d2019-09-12 22:20:37 +08001204 def test_issue21872(self):
1205 # sometimes decompress data incompletely
1206
1207 # ---------------------
1208 # when max_length == -1
1209 # ---------------------
1210 d1 = LZMADecompressor()
1211 entire = d1.decompress(ISSUE_21872_DAT, max_length=-1)
1212 self.assertEqual(len(entire), 13160)
1213 self.assertTrue(d1.eof)
1214
1215 # ---------------------
1216 # when max_length > 0
1217 # ---------------------
1218 d2 = LZMADecompressor()
1219
1220 # When this value of max_length is used, the input and output
1221 # buffers are exhausted at the same time, and lzs's internal
1222 # state still have 11 bytes can be output.
1223 out1 = d2.decompress(ISSUE_21872_DAT, max_length=13149)
1224 self.assertFalse(d2.needs_input) # ensure needs_input mechanism works
1225 self.assertFalse(d2.eof)
1226
1227 # simulate needs_input mechanism
1228 # output internal state's 11 bytes
1229 out2 = d2.decompress(b'')
1230 self.assertEqual(len(out2), 11)
1231 self.assertTrue(d2.eof)
1232 self.assertEqual(out1 + out2, entire)
1233
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001234
Nadeem Vawdae8604042012-06-04 23:38:12 +02001235class OpenTestCase(unittest.TestCase):
1236
1237 def test_binary_modes(self):
1238 with lzma.open(BytesIO(COMPRESSED_XZ), "rb") as f:
1239 self.assertEqual(f.read(), INPUT)
1240 with BytesIO() as bio:
1241 with lzma.open(bio, "wb") as f:
1242 f.write(INPUT)
1243 file_data = lzma.decompress(bio.getvalue())
1244 self.assertEqual(file_data, INPUT)
1245 with lzma.open(bio, "ab") as f:
1246 f.write(INPUT)
1247 file_data = lzma.decompress(bio.getvalue())
1248 self.assertEqual(file_data, INPUT * 2)
1249
1250 def test_text_modes(self):
1251 uncompressed = INPUT.decode("ascii")
1252 uncompressed_raw = uncompressed.replace("\n", os.linesep)
Inada Naoki4663e5f2021-04-06 13:02:22 +09001253 with lzma.open(BytesIO(COMPRESSED_XZ), "rt", encoding="ascii") as f:
Nadeem Vawdae8604042012-06-04 23:38:12 +02001254 self.assertEqual(f.read(), uncompressed)
1255 with BytesIO() as bio:
Inada Naoki4663e5f2021-04-06 13:02:22 +09001256 with lzma.open(bio, "wt", encoding="ascii") as f:
Nadeem Vawdae8604042012-06-04 23:38:12 +02001257 f.write(uncompressed)
1258 file_data = lzma.decompress(bio.getvalue()).decode("ascii")
1259 self.assertEqual(file_data, uncompressed_raw)
Inada Naoki4663e5f2021-04-06 13:02:22 +09001260 with lzma.open(bio, "at", encoding="ascii") as f:
Nadeem Vawdae8604042012-06-04 23:38:12 +02001261 f.write(uncompressed)
1262 file_data = lzma.decompress(bio.getvalue()).decode("ascii")
1263 self.assertEqual(file_data, uncompressed_raw * 2)
1264
1265 def test_filename(self):
1266 with TempFile(TESTFN):
1267 with lzma.open(TESTFN, "wb") as f:
1268 f.write(INPUT)
1269 with open(TESTFN, "rb") as f:
1270 file_data = lzma.decompress(f.read())
1271 self.assertEqual(file_data, INPUT)
1272 with lzma.open(TESTFN, "rb") as f:
1273 self.assertEqual(f.read(), INPUT)
1274 with lzma.open(TESTFN, "ab") as f:
1275 f.write(INPUT)
1276 with lzma.open(TESTFN, "rb") as f:
1277 self.assertEqual(f.read(), INPUT * 2)
1278
Berker Peksag5f59ddd2016-10-04 20:41:20 +03001279 def test_with_pathlike_filename(self):
1280 filename = pathlib.Path(TESTFN)
1281 with TempFile(filename):
1282 with lzma.open(filename, "wb") as f:
1283 f.write(INPUT)
1284 with open(filename, "rb") as f:
1285 file_data = lzma.decompress(f.read())
1286 self.assertEqual(file_data, INPUT)
1287 with lzma.open(filename, "rb") as f:
1288 self.assertEqual(f.read(), INPUT)
1289
Nadeem Vawdae8604042012-06-04 23:38:12 +02001290 def test_bad_params(self):
1291 # Test invalid parameter combinations.
1292 with self.assertRaises(ValueError):
1293 lzma.open(TESTFN, "")
1294 with self.assertRaises(ValueError):
Nadeem Vawdae8604042012-06-04 23:38:12 +02001295 lzma.open(TESTFN, "rbt")
1296 with self.assertRaises(ValueError):
1297 lzma.open(TESTFN, "rb", encoding="utf-8")
1298 with self.assertRaises(ValueError):
1299 lzma.open(TESTFN, "rb", errors="ignore")
1300 with self.assertRaises(ValueError):
1301 lzma.open(TESTFN, "rb", newline="\n")
1302
1303 def test_format_and_filters(self):
1304 # Test non-default format and filter chain.
1305 options = {"format": lzma.FORMAT_RAW, "filters": FILTERS_RAW_1}
1306 with lzma.open(BytesIO(COMPRESSED_RAW_1), "rb", **options) as f:
1307 self.assertEqual(f.read(), INPUT)
1308 with BytesIO() as bio:
1309 with lzma.open(bio, "wb", **options) as f:
1310 f.write(INPUT)
1311 file_data = lzma.decompress(bio.getvalue(), **options)
1312 self.assertEqual(file_data, INPUT)
1313
1314 def test_encoding(self):
1315 # Test non-default encoding.
1316 uncompressed = INPUT.decode("ascii")
1317 uncompressed_raw = uncompressed.replace("\n", os.linesep)
1318 with BytesIO() as bio:
1319 with lzma.open(bio, "wt", encoding="utf-16-le") as f:
1320 f.write(uncompressed)
1321 file_data = lzma.decompress(bio.getvalue()).decode("utf-16-le")
1322 self.assertEqual(file_data, uncompressed_raw)
1323 bio.seek(0)
1324 with lzma.open(bio, "rt", encoding="utf-16-le") as f:
1325 self.assertEqual(f.read(), uncompressed)
1326
1327 def test_encoding_error_handler(self):
Martin Panter46f50722016-05-26 05:35:26 +00001328 # Test with non-default encoding error handler.
Nadeem Vawdae8604042012-06-04 23:38:12 +02001329 with BytesIO(lzma.compress(b"foo\xffbar")) as bio:
1330 with lzma.open(bio, "rt", encoding="ascii", errors="ignore") as f:
1331 self.assertEqual(f.read(), "foobar")
1332
1333 def test_newline(self):
1334 # Test with explicit newline (universal newline mode disabled).
1335 text = INPUT.decode("ascii")
1336 with BytesIO() as bio:
Inada Naoki4663e5f2021-04-06 13:02:22 +09001337 with lzma.open(bio, "wt", encoding="ascii", newline="\n") as f:
Nadeem Vawdae8604042012-06-04 23:38:12 +02001338 f.write(text)
1339 bio.seek(0)
Inada Naoki4663e5f2021-04-06 13:02:22 +09001340 with lzma.open(bio, "rt", encoding="ascii", newline="\r") as f:
Nadeem Vawdae8604042012-06-04 23:38:12 +02001341 self.assertEqual(f.readlines(), [text])
1342
Nadeem Vawda42ca9822013-10-19 00:06:19 +02001343 def test_x_mode(self):
1344 self.addCleanup(unlink, TESTFN)
1345 for mode in ("x", "xb", "xt"):
1346 unlink(TESTFN)
Inada Naoki4663e5f2021-04-06 13:02:22 +09001347 encoding = "ascii" if "t" in mode else None
1348 with lzma.open(TESTFN, mode, encoding=encoding):
Nadeem Vawda42ca9822013-10-19 00:06:19 +02001349 pass
1350 with self.assertRaises(FileExistsError):
1351 with lzma.open(TESTFN, mode):
1352 pass
1353
Nadeem Vawdae8604042012-06-04 23:38:12 +02001354
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001355class MiscellaneousTestCase(unittest.TestCase):
1356
1357 def test_is_check_supported(self):
1358 # CHECK_NONE and CHECK_CRC32 should always be supported,
1359 # regardless of the options liblzma was compiled with.
Nadeem Vawdabc459bb2012-05-06 23:01:51 +02001360 self.assertTrue(lzma.is_check_supported(lzma.CHECK_NONE))
1361 self.assertTrue(lzma.is_check_supported(lzma.CHECK_CRC32))
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001362
1363 # The .xz format spec cannot store check IDs above this value.
Nadeem Vawdabc459bb2012-05-06 23:01:51 +02001364 self.assertFalse(lzma.is_check_supported(lzma.CHECK_ID_MAX + 1))
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001365
1366 # This value should not be a valid check ID.
Nadeem Vawdabc459bb2012-05-06 23:01:51 +02001367 self.assertFalse(lzma.is_check_supported(lzma.CHECK_UNKNOWN))
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001368
Nadeem Vawdaa425c3d2012-06-21 23:36:48 +02001369 def test__encode_filter_properties(self):
Nadeem Vawdaf55b3292012-05-06 23:01:27 +02001370 with self.assertRaises(TypeError):
Nadeem Vawdaa425c3d2012-06-21 23:36:48 +02001371 lzma._encode_filter_properties(b"not a dict")
Nadeem Vawdaf55b3292012-05-06 23:01:27 +02001372 with self.assertRaises(ValueError):
Nadeem Vawdaa425c3d2012-06-21 23:36:48 +02001373 lzma._encode_filter_properties({"id": 0x100})
Nadeem Vawdaf55b3292012-05-06 23:01:27 +02001374 with self.assertRaises(ValueError):
Nadeem Vawdaa425c3d2012-06-21 23:36:48 +02001375 lzma._encode_filter_properties({"id": lzma.FILTER_LZMA2, "junk": 12})
Nadeem Vawdaf55b3292012-05-06 23:01:27 +02001376 with self.assertRaises(lzma.LZMAError):
Nadeem Vawdaa425c3d2012-06-21 23:36:48 +02001377 lzma._encode_filter_properties({"id": lzma.FILTER_DELTA,
Nadeem Vawdaf55b3292012-05-06 23:01:27 +02001378 "dist": 9001})
1379
1380 # Test with parameters used by zipfile module.
Nadeem Vawdaa425c3d2012-06-21 23:36:48 +02001381 props = lzma._encode_filter_properties({
Nadeem Vawdaf55b3292012-05-06 23:01:27 +02001382 "id": lzma.FILTER_LZMA1,
1383 "pb": 2,
1384 "lp": 0,
1385 "lc": 3,
1386 "dict_size": 8 << 20,
1387 })
1388 self.assertEqual(props, b"]\x00\x00\x80\x00")
1389
Nadeem Vawdaa425c3d2012-06-21 23:36:48 +02001390 def test__decode_filter_properties(self):
Nadeem Vawdaf55b3292012-05-06 23:01:27 +02001391 with self.assertRaises(TypeError):
Nadeem Vawdaa425c3d2012-06-21 23:36:48 +02001392 lzma._decode_filter_properties(lzma.FILTER_X86, {"should be": bytes})
Nadeem Vawdaf55b3292012-05-06 23:01:27 +02001393 with self.assertRaises(lzma.LZMAError):
Nadeem Vawdaa425c3d2012-06-21 23:36:48 +02001394 lzma._decode_filter_properties(lzma.FILTER_DELTA, b"too long")
Nadeem Vawdaf55b3292012-05-06 23:01:27 +02001395
1396 # Test with parameters used by zipfile module.
Nadeem Vawdaa425c3d2012-06-21 23:36:48 +02001397 filterspec = lzma._decode_filter_properties(
Nadeem Vawdaf55b3292012-05-06 23:01:27 +02001398 lzma.FILTER_LZMA1, b"]\x00\x00\x80\x00")
1399 self.assertEqual(filterspec["id"], lzma.FILTER_LZMA1)
1400 self.assertEqual(filterspec["pb"], 2)
1401 self.assertEqual(filterspec["lp"], 0)
1402 self.assertEqual(filterspec["lc"], 3)
1403 self.assertEqual(filterspec["dict_size"], 8 << 20)
1404
1405 def test_filter_properties_roundtrip(self):
Nadeem Vawdaa425c3d2012-06-21 23:36:48 +02001406 spec1 = lzma._decode_filter_properties(
Nadeem Vawdaf55b3292012-05-06 23:01:27 +02001407 lzma.FILTER_LZMA1, b"]\x00\x00\x80\x00")
Nadeem Vawdaa425c3d2012-06-21 23:36:48 +02001408 reencoded = lzma._encode_filter_properties(spec1)
1409 spec2 = lzma._decode_filter_properties(lzma.FILTER_LZMA1, reencoded)
Nadeem Vawdaf55b3292012-05-06 23:01:27 +02001410 self.assertEqual(spec1, spec2)
1411
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001412
1413# Test data:
1414
1415INPUT = b"""
1416LAERTES
1417
1418 O, fear me not.
1419 I stay too long: but here my father comes.
1420
1421 Enter POLONIUS
1422
1423 A double blessing is a double grace,
1424 Occasion smiles upon a second leave.
1425
1426LORD POLONIUS
1427
1428 Yet here, Laertes! aboard, aboard, for shame!
1429 The wind sits in the shoulder of your sail,
1430 And you are stay'd for. There; my blessing with thee!
1431 And these few precepts in thy memory
1432 See thou character. Give thy thoughts no tongue,
1433 Nor any unproportioned thought his act.
1434 Be thou familiar, but by no means vulgar.
1435 Those friends thou hast, and their adoption tried,
1436 Grapple them to thy soul with hoops of steel;
1437 But do not dull thy palm with entertainment
1438 Of each new-hatch'd, unfledged comrade. Beware
1439 Of entrance to a quarrel, but being in,
1440 Bear't that the opposed may beware of thee.
1441 Give every man thy ear, but few thy voice;
1442 Take each man's censure, but reserve thy judgment.
1443 Costly thy habit as thy purse can buy,
1444 But not express'd in fancy; rich, not gaudy;
1445 For the apparel oft proclaims the man,
1446 And they in France of the best rank and station
1447 Are of a most select and generous chief in that.
1448 Neither a borrower nor a lender be;
1449 For loan oft loses both itself and friend,
1450 And borrowing dulls the edge of husbandry.
1451 This above all: to thine ownself be true,
1452 And it must follow, as the night the day,
1453 Thou canst not then be false to any man.
1454 Farewell: my blessing season this in thee!
1455
1456LAERTES
1457
1458 Most humbly do I take my leave, my lord.
1459
1460LORD POLONIUS
1461
1462 The time invites you; go; your servants tend.
1463
1464LAERTES
1465
1466 Farewell, Ophelia; and remember well
1467 What I have said to you.
1468
1469OPHELIA
1470
1471 'Tis in my memory lock'd,
1472 And you yourself shall keep the key of it.
1473
1474LAERTES
1475
1476 Farewell.
1477"""
1478
Nadeem Vawda9c72ebc2013-12-04 23:03:49 +01001479COMPRESSED_BOGUS = b"this is not a valid lzma stream"
1480
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001481COMPRESSED_XZ = (
1482 b"\xfd7zXZ\x00\x00\x04\xe6\xd6\xb4F\x02\x00!\x01\x16\x00\x00\x00t/\xe5\xa3"
1483 b"\xe0\x07\x80\x03\xdf]\x00\x05\x14\x07bX\x19\xcd\xddn\x98\x15\xe4\xb4\x9d"
1484 b"o\x1d\xc4\xe5\n\x03\xcc2h\xc7\\\x86\xff\xf8\xe2\xfc\xe7\xd9\xfe6\xb8("
1485 b"\xa8wd\xc2\"u.n\x1e\xc3\xf2\x8e\x8d\x8f\x02\x17/\xa6=\xf0\xa2\xdf/M\x89"
1486 b"\xbe\xde\xa7\x1cz\x18-]\xd5\xef\x13\x8frZ\x15\x80\x8c\xf8\x8do\xfa\x12"
1487 b"\x9b#z/\xef\xf0\xfaF\x01\x82\xa3M\x8e\xa1t\xca6 BF$\xe5Q\xa4\x98\xee\xde"
1488 b"l\xe8\x7f\xf0\x9d,bn\x0b\x13\xd4\xa8\x81\xe4N\xc8\x86\x153\xf5x2\xa2O"
1489 b"\x13@Q\xa1\x00/\xa5\xd0O\x97\xdco\xae\xf7z\xc4\xcdS\xb6t<\x16\xf2\x9cI#"
1490 b"\x89ud\xc66Y\xd9\xee\xe6\xce\x12]\xe5\xf0\xaa\x96-Pe\xade:\x04\t\x1b\xf7"
1491 b"\xdb7\n\x86\x1fp\xc8J\xba\xf4\xf0V\xa9\xdc\xf0\x02%G\xf9\xdf=?\x15\x1b"
1492 b"\xe1(\xce\x82=\xd6I\xac3\x12\x0cR\xb7\xae\r\xb1i\x03\x95\x01\xbd\xbe\xfa"
1493 b"\x02s\x01P\x9d\x96X\xb12j\xc8L\xa8\x84b\xf6\xc3\xd4c-H\x93oJl\xd0iQ\xe4k"
1494 b"\x84\x0b\xc1\xb7\xbc\xb1\x17\x88\xb1\xca?@\xf6\x07\xea\xe6x\xf1H12P\x0f"
1495 b"\x8a\xc9\xeauw\xe3\xbe\xaai\xa9W\xd0\x80\xcd#cb5\x99\xd8]\xa9d\x0c\xbd"
1496 b"\xa2\xdcWl\xedUG\xbf\x89yF\xf77\x81v\xbd5\x98\xbeh8\x18W\x08\xf0\x1b\x99"
1497 b"5:\x1a?rD\x96\xa1\x04\x0f\xae\xba\x85\xeb\x9d5@\xf5\x83\xd37\x83\x8ac"
1498 b"\x06\xd4\x97i\xcdt\x16S\x82k\xf6K\x01vy\x88\x91\x9b6T\xdae\r\xfd]:k\xbal"
1499 b"\xa9\xbba\xc34\xf9r\xeb}r\xdb\xc7\xdb*\x8f\x03z\xdc8h\xcc\xc9\xd3\xbcl"
1500 b"\xa5-\xcb\xeaK\xa2\xc5\x15\xc0\xe3\xc1\x86Z\xfb\xebL\xe13\xcf\x9c\xe3"
1501 b"\x1d\xc9\xed\xc2\x06\xcc\xce!\x92\xe5\xfe\x9c^\xa59w \x9bP\xa3PK\x08d"
1502 b"\xf9\xe2Z}\xa7\xbf\xed\xeb%$\x0c\x82\xb8/\xb0\x01\xa9&,\xf7qh{Q\x96)\xf2"
1503 b"q\x96\xc3\x80\xb4\x12\xb0\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f\x19\xb8\r\xa8\xf8\x1f$\xa5{p"
1518 b"\xc6\x880\xce\xdb\xcf\xca_\x86\xac\x88h6\x8bZ%'\xd0\n\xbf\x0f\x9c\"\xba"
1519 b"\xe5\x86\x9f\x0f7X=mNX[\xcc\x19FU\xc9\x860\xbc\x90a+* \xae_$\x03\x1e\xd3"
1520 b"\xcd_\xa0\x9c\xde\xaf46q\xa5\xc9\x92\xd7\xca\xe3`\x9d\x85}\xb4\xff\xb3"
1521 b"\x83\xfb\xb6\xca\xae`\x0bw\x7f\xfc\xd8\xacVe\x19\xc8\x17\x0bZ\xad\x88"
1522 b"\xeb#\x97\x03\x13\xb1d\x0f{\x0c\x04w\x07\r\x97\xbd\xd6\xc1\xc3B:\x95\x08"
1523 b"^\x10V\xaeaH\x02\xd9\xe3\n\\\x01X\xf6\x9c\x8a\x06u#%\xbe*\xa1\x18v\x85"
1524 b"\xec!\t4\x00\x00\x00\x00Vj?uLU\xf3\xa6\x00\x01\xfb\x07\x81\x0f\x00\x00tw"
1525 b"\x99P\xb1\xc4g\xfb\x02\x00\x00\x00\x00\x04YZ"
1526)
1527
1528COMPRESSED_ALONE = (
1529 b"]\x00\x00\x80\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x05\x14\x07bX\x19"
1530 b"\xcd\xddn\x98\x15\xe4\xb4\x9do\x1d\xc4\xe5\n\x03\xcc2h\xc7\\\x86\xff\xf8"
1531 b"\xe2\xfc\xe7\xd9\xfe6\xb8(\xa8wd\xc2\"u.n\x1e\xc3\xf2\x8e\x8d\x8f\x02"
1532 b"\x17/\xa6=\xf0\xa2\xdf/M\x89\xbe\xde\xa7\x1cz\x18-]\xd5\xef\x13\x8frZ"
1533 b"\x15\x80\x8c\xf8\x8do\xfa\x12\x9b#z/\xef\xf0\xfaF\x01\x82\xa3M\x8e\xa1t"
1534 b"\xca6 BF$\xe5Q\xa4\x98\xee\xdel\xe8\x7f\xf0\x9d,bn\x0b\x13\xd4\xa8\x81"
1535 b"\xe4N\xc8\x86\x153\xf5x2\xa2O\x13@Q\xa1\x00/\xa5\xd0O\x97\xdco\xae\xf7z"
1536 b"\xc4\xcdS\xb6t<\x16\xf2\x9cI#\x89ud\xc66Y\xd9\xee\xe6\xce\x12]\xe5\xf0"
1537 b"\xaa\x96-Pe\xade:\x04\t\x1b\xf7\xdb7\n\x86\x1fp\xc8J\xba\xf4\xf0V\xa9"
1538 b"\xdc\xf0\x02%G\xf9\xdf=?\x15\x1b\xe1(\xce\x82=\xd6I\xac3\x12\x0cR\xb7"
1539 b"\xae\r\xb1i\x03\x95\x01\xbd\xbe\xfa\x02s\x01P\x9d\x96X\xb12j\xc8L\xa8"
1540 b"\x84b\xf8\x1epl\xeajr\xd1=\t\x03\xdd\x13\x1b3!E\xf9vV\xdaF\xf3\xd7\xb4"
1541 b"\x0c\xa9P~\xec\xdeE\xe37\xf6\x1d\xc6\xbb\xddc%\xb6\x0fI\x07\xf0;\xaf\xe7"
1542 b"\xa0\x8b\xa7Z\x99(\xe9\xe2\xf0o\x18>`\xe1\xaa\xa8\xd9\xa1\xb2}\xe7\x8d"
1543 b"\x834T\xb6\xef\xc1\xde\xe3\x98\xbcD\x03MA@\xd8\xed\xdc\xc8\x93\x03\x1a"
1544 b"\x93\x0b\x7f\x94\x12\x0b\x02Sa\x18\xc9\xc5\x9bTJE}\xf6\xc8g\x17#ZV\x01"
1545 b"\xc9\x9dc\x83\x0e>0\x16\x90S\xb8/\x03y_\x18\xfa(\xd7\x0br\xa2\xb0\xba?"
1546 b"\x8c\xe6\x83@\x84\xdf\x02:\xc5z\x9e\xa6\x84\xc9\xf5BeyX\x83\x1a\xf1 :\t"
1547 b"\xf7\x19\xfexD\\&G\xf3\x85Y\xa2J\xf9\x0bv{\x89\xf6\xe7)A\xaf\x04o\x00"
1548 b"\x075\xd3\xe0\x7f\x97\x98F\x0f?v\x93\xedVtTf\xb5\x97\x83\xed\x19\xd7\x1a"
1549 b"'k\xd7\xd9\xc5\\Y\xd1\xdc\x07\x15|w\xbc\xacd\x87\x08d\xec\xa7\xf6\x82"
1550 b"\xfc\xb3\x93\xeb\xb9 \x8d\xbc ,\xb3X\xb0\xd2s\xd7\xd1\xffv\x05\xdf}\xa2"
1551 b"\x96\xfb%\n\xdf\xa2\x7f\x08.\xa16\n\xe0\x19\x93\x7fh\n\x1c\x8c\x0f \x11"
1552 b"\xc6Bl\x95\x19U}\xe4s\xb5\x10H\xea\x86pB\xe88\x95\xbe\x8cZ\xdb\xe4\x94A"
1553 b"\x92\xb9;z\xaa\xa7{\x1c5!\xc0\xaf\xc1A\xf9\xda\xf0$\xb0\x02qg\xc8\xc7/|"
1554 b"\xafr\x99^\x91\x88\xbf\x03\xd9=\xd7n\xda6{>8\n\xc7:\xa9'\xba.\x0b\xe2"
1555 b"\xb5\x1d\x0e\n\x9a\x8e\x06\x8f:\xdd\x82'[\xc3\"wD$\xa7w\xecq\x8c,1\x93"
1556 b"\xd0,\xae2w\x93\x12$Jd\x19mg\x02\x93\x9cA\x95\x9d&\xca8i\x9c\xb0;\xe7NQ"
1557 b"\x1frh\x8beL;\xb0m\xee\x07Q\x9b\xc6\xd8\x03\xb5\xdeN\xd4\xfe\x98\xd0\xdc"
1558 b"\x1a[\x04\xde\x1a\xf6\x91j\xf8EOli\x8eB^\x1d\x82\x07\xb2\xb5R]\xb7\xd7"
1559 b"\xe9\xa6\xc3.\xfb\xf0-\xb4e\x9b\xde\x03\x88\xc6\xc1iN\x0e\x84wbQ\xdf~"
1560 b"\xe9\xa4\x884\x96kM\xbc)T\xf3\x89\x97\x0f\x143\xe7)\xa0\xb3B\x00\xa8\xaf"
1561 b"\x82^\xcb\xc7..\xdb\xc7\t\x9dH\xee5\xe9#\xe6NV\x94\xcb$Kk\xe3\x7f\r\xe3t"
1562 b"\x12\xcf'\xefR\x8b\xf42\xcf-LH\xac\xe5\x1f0~?SO\xeb\xc1E\x1a\x1c]\xf2"
1563 b"\xc4<\x11\x02\x10Z0a*?\xe4r\xff\xfb\xff\xf6\x14nG\xead^\xd6\xef8\xb6uEI"
1564 b"\x99\nV\xe2\xb3\x95\x8e\x83\xf6i!\xb5&1F\xb1DP\xf4 SO3D!w\x99_G\x7f+\x90"
1565 b".\xab\xbb]\x91>\xc9#h;\x0f5J\x91K\xf4^-[\x9e\x8a\\\x94\xca\xaf\xf6\x19"
1566 b"\xd4\xa1\x9b\xc4\xb8p\xa1\xae\x15\xe9r\x84\xe0\xcar.l []\x8b\xaf+0\xf2g"
1567 b"\x01aKY\xdfI\xcf,\n\xe8\xf0\xe7V\x80_#\xb2\xf2\xa9\x06\x8c>w\xe2W,\xf4"
1568 b"\x8c\r\xf963\xf5J\xcc2\x05=kT\xeaUti\xe5_\xce\x1b\xfa\x8dl\x02h\xef\xa8"
1569 b"\xfbf\x7f\xff\xf0\x19\xeax"
1570)
1571
1572FILTERS_RAW_1 = [{"id": lzma.FILTER_LZMA2, "preset": 3}]
1573COMPRESSED_RAW_1 = (
1574 b"\xe0\x07\x80\x03\xfd]\x00\x05\x14\x07bX\x19\xcd\xddn\x96cyq\xa1\xdd\xee"
1575 b"\xf8\xfam\xe3'\x88\xd3\xff\xe4\x9e \xceQ\x91\xa4\x14I\xf6\xb9\x9dVL8\x15"
1576 b"_\x0e\x12\xc3\xeb\xbc\xa5\xcd\nW\x1d$=R;\x1d\xf8k8\t\xb1{\xd4\xc5+\x9d"
1577 b"\x87c\xe5\xef\x98\xb4\xd7S3\xcd\xcc\xd2\xed\xa4\x0em\xe5\xf4\xdd\xd0b"
1578 b"\xbe4*\xaa\x0b\xc5\x08\x10\x85+\x81.\x17\xaf9\xc9b\xeaZrA\xe20\x7fs\"r"
1579 b"\xdaG\x81\xde\x90cu\xa5\xdb\xa9.A\x08l\xb0<\xf6\x03\xddOi\xd0\xc5\xb4"
1580 b"\xec\xecg4t6\"\xa6\xb8o\xb5?\x18^}\xb6}\x03[:\xeb\x03\xa9\n[\x89l\x19g"
1581 b"\x16\xc82\xed\x0b\xfb\x86n\xa2\x857@\x93\xcd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a5\xd7\xc0gX\x98\xcf\x0f"
1596 b"\xcd3\x00]n\x17\xec\xbd\xa3Y\x86\xc5\xf3u\xf6*\xbdT\xedA$A\xd9A\xe7\x98"
1597 b"\xef\x14\x02\x9a\xfdiw\xec\xa0\x87\x11\xd9%\xc5\xeb\x8a=\xae\xc0\xc4\xc6"
1598 b"D\x80\x8f\xa8\xd1\xbbq\xb2\xc0\xa0\xf5Cqp\xeeL\xe3\xe5\xdc \x84\"\xe9"
1599 b"\x80t\x83\x05\xba\xf1\xc5~\x93\xc9\xf0\x01c\xceix\x9d\xed\xc5)l\x16)\xd1"
1600 b"\x03@l\x04\x7f\x87\xa5yn\x1b\x01D\xaa:\xd2\x96\xb4\xb3?\xb0\xf9\xce\x07"
1601 b"\xeb\x81\x00\xe4\xc3\xf5%_\xae\xd4\xf9\xeb\xe2\rh\xb2#\xd67Q\x16D\x82hn"
1602 b"\xd1\xa3_?q\xf0\xe2\xac\xf317\x9e\xd0_\x83|\xf1\xca\xb7\x95S\xabW\x12"
1603 b"\xff\xddt\xf69L\x01\xf2|\xdaW\xda\xees\x98L\x18\xb8_\xe8$\x82\xea\xd6"
1604 b"\xd1F\xd4\x0b\xcdk\x01vf\x88h\xc3\xae\xb91\xc7Q\x9f\xa5G\xd9\xcc\x1f\xe3"
1605 b"5\xb1\xdcy\x7fI\x8bcw\x8e\x10rIp\x02:\x19p_\xc8v\xcea\"\xc1\xd9\x91\x03"
1606 b"\xbfe\xbe\xa6\xb3\xa8\x14\x18\xc3\xabH*m}\xc2\xc1\x9a}>l%\xce\x84\x99"
1607 b"\xb3d\xaf\xd3\x82\x15\xdf\xc1\xfc5fOg\x9b\xfc\x8e^&\t@\xce\x9f\x06J\xb8"
1608 b"\xb5\x86\x1d\xda{\x9f\xae\xb0\xff\x02\x81r\x92z\x8cM\xb7ho\xc9^\x9c\xb6"
1609 b"\x9c\xae\xd1\xc9\xf4\xdfU7\xd6\\!\xea\x0b\x94k\xb9Ud~\x98\xe7\x86\x8az"
1610 b"\x10;\xe3\x1d\xe5PG\xf8\xa4\x12\x05w\x98^\xc4\xb1\xbb\xfb\xcf\xe0\x7f"
1611 b"\x033Sf\x0c \xb1\xf6@\x94\xe5\xa3\xb2\xa7\x10\x9a\xc0\x14\xc3s\xb5xRD"
1612 b"\xf4`W\xd9\xe5\xd3\xcf\x91\rTZ-X\xbe\xbf\xb5\xe2\xee|\x1a\xbf\xfb\x08"
1613 b"\x91\xe1\xfc\x9a\x18\xa3\x8b\xd6^\x89\xf5[\xef\x87\xd1\x06\x1c7\xd6\xa2"
1614 b"\t\tQ5/@S\xc05\xd2VhAK\x03VC\r\x9b\x93\xd6M\xf1xO\xaaO\xed\xb9<\x0c\xdae"
1615 b"*\xd0\x07Hk6\x9fG+\xa1)\xcd\x9cl\x87\xdb\xe1\xe7\xefK}\x875\xab\xa0\x19u"
1616 b"\xf6*F\xb32\x00\x00\x00"
1617)
1618
1619FILTERS_RAW_2 = [{"id": lzma.FILTER_DELTA, "dist": 2},
1620 {"id": lzma.FILTER_LZMA2,
1621 "preset": lzma.PRESET_DEFAULT | lzma.PRESET_EXTREME}]
1622COMPRESSED_RAW_2 = (
1623 b"\xe0\x07\x80\x05\x91]\x00\x05\x14\x06-\xd4\xa8d?\xef\xbe\xafH\xee\x042"
1624 b"\xcb.\xb5g\x8f\xfb\x14\xab\xa5\x9f\x025z\xa4\xdd\xd8\t[}W\xf8\x0c\x1dmH"
1625 b"\xfa\x05\xfcg\xba\xe5\x01Q\x0b\x83R\xb6A\x885\xc0\xba\xee\n\x1cv~\xde:o"
1626 b"\x06:J\xa7\x11Cc\xea\xf7\xe5*o\xf7\x83\\l\xbdE\x19\x1f\r\xa8\x10\xb42"
1627 b"\x0caU{\xd7\xb8w\xdc\xbe\x1b\xfc8\xb4\xcc\xd38\\\xf6\x13\xf6\xe7\x98\xfa"
1628 b"\xc7[\x17_9\x86%\xa8\xf8\xaa\xb8\x8dfs#\x1e=\xed<\x92\x10\\t\xff\x86\xfb"
1629 b"=\x9e7\x18\x1dft\\\xb5\x01\x95Q\xc5\x19\xb38\xe0\xd4\xaa\x07\xc3\x7f\xd8"
1630 b"\xa2\x00>-\xd3\x8e\xa1#\xfa\x83ArAm\xdbJ~\x93\xa3B\x82\xe0\xc7\xcc(\x08`"
1631 b"WK\xad\x1b\x94kaj\x04 \xde\xfc\xe1\xed\xb0\x82\x91\xefS\x84%\x86\xfbi"
1632 b"\x99X\xf1B\xe7\x90;E\xfde\x98\xda\xca\xd6T\xb4bg\xa4\n\x9aj\xd1\x83\x9e]"
1633 b"\"\x7fM\xb5\x0fr\xd2\\\xa5j~P\x10GH\xbfN*Z\x10.\x81\tpE\x8a\x08\xbe1\xbd"
1634 b"\xcd\xa9\xe1\x8d\x1f\x04\xf9\x0eH\xb9\xae\xd6\xc3\xc1\xa5\xa9\x95P\xdc~"
1635 b"\xff\x01\x930\xa9\x04\xf6\x03\xfe\xb5JK\xc3]\xdd9\xb1\xd3\xd7F\xf5\xd1"
1636 b"\x1e\xa0\x1c_\xed[\x0c\xae\xd4\x8b\x946\xeb\xbf\xbb\xe3$kS{\xb5\x80,f:Sj"
1637 b"\x0f\x08z\x1c\xf5\xe8\xe6\xae\x98\xb0Q~r\x0f\xb0\x05?\xb6\x90\x19\x02&"
1638 b"\xcb\x80\t\xc4\xea\x9c|x\xce\x10\x9c\xc5|\xcbdhh+\x0c'\xc5\x81\xc33\xb5"
1639 b"\x14q\xd6\xc5\xe3`Z#\xdc\x8a\xab\xdd\xea\x08\xc2I\xe7\x02l{\xec\x196\x06"
1640 b"\x91\x8d\xdc\xd5\xb3x\xe1hz%\xd1\xf8\xa5\xdd\x98!\x8c\x1c\xc1\x17RUa\xbb"
1641 b"\x95\x0f\xe4X\xea1\x0c\xf1=R\xbe\xc60\xe3\xa4\x9a\x90bd\x97$]B\x01\xdd"
1642 b"\x1f\xe3h2c\x1e\xa0L`4\xc6x\xa3Z\x8a\r\x14]T^\xd8\x89\x1b\x92\r;\xedY"
1643 b"\x0c\x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\x13)ff\xf9n\xc4\xa9\xe3\x01\xb8\xda\xfb\xab\xdfM\x99\xfb\x05"
1658 b"\xe0\xe9\xb0I\xf4E\xab\xe2\x15\xa3\x035\xe7\xdeT\xee\x82p\xb4\x88\xd3"
1659 b"\x893\x9c/\xc0\xd6\x8fou;\xf6\x95PR\xa9\xb2\xc1\xefFj\xe2\xa7$\xf7h\xf1"
1660 b"\xdfK(\xc9c\xba7\xe8\xe3)\xdd\xb2,\x83\xfb\x84\x18.y\x18Qi\x88\xf8`h-"
1661 b"\xef\xd5\xed\x8c\t\xd8\xc3^\x0f\x00\xb7\xd0[!\xafM\x9b\xd7.\x07\xd8\xfb"
1662 b"\xd9\xe2-S+\xaa8,\xa0\x03\x1b \xea\xa8\x00\xc3\xab~\xd0$e\xa5\x7f\xf7"
1663 b"\x95P]\x12\x19i\xd9\x7fo\x0c\xd8g^\rE\xa5\x80\x18\xc5\x01\x80\xaek`\xff~"
1664 b"\xb6y\xe7+\xe5\x11^D\xa7\x85\x18\"!\xd6\xd2\xa7\xf4\x1eT\xdb\x02\xe15"
1665 b"\x02Y\xbc\x174Z\xe7\x9cH\x1c\xbf\x0f\xc6\xe9f]\xcf\x8cx\xbc\xe5\x15\x94"
1666 b"\xfc3\xbc\xa7TUH\xf1\x84\x1b\xf7\xa9y\xc07\x84\xf8X\xd8\xef\xfc \x1c\xd8"
1667 b"( /\xf2\xb7\xec\xc1\\\x8c\xf6\x95\xa1\x03J\x83vP8\xe1\xe3\xbb~\xc24kA"
1668 b"\x98y\xa1\xf2P\xe9\x9d\xc9J\xf8N\x99\xb4\xceaO\xde\x16\x1e\xc2\x19\xa7"
1669 b"\x03\xd2\xe0\x8f:\x15\xf3\x84\x9e\xee\xe6e\xb8\x02q\xc7AC\x1emw\xfd\t"
1670 b"\x9a\x1eu\xc1\xa9\xcaCwUP\x00\xa5\xf78L4w!\x91L2 \x87\xd0\xf2\x06\x81j"
1671 b"\x80;\x03V\x06\x87\x92\xcb\x90lv@E\x8d\x8d\xa5\xa6\xe7Z[\xdf\xd6E\x03`>"
1672 b"\x8f\xde\xa1bZ\x84\xd0\xa9`\x05\x0e{\x80;\xe3\xbef\x8d\x1d\xebk1.\xe3"
1673 b"\xe9N\x15\xf7\xd4(\xfa\xbb\x15\xbdu\xf7\x7f\x86\xae!\x03L\x1d\xb5\xc1"
1674 b"\xb9\x11\xdb\xd0\x93\xe4\x02\xe1\xd2\xcbBjc_\xe8}d\xdb\xc3\xa0Y\xbe\xc9/"
1675 b"\x95\x01\xa3,\xe6bl@\x01\xdbp\xc2\xce\x14\x168\xc2q\xe3uH\x89X\xa4\xa9"
1676 b"\x19\x1d\xc1}\x7fOX\x19\x9f\xdd\xbe\x85\x83\xff\x96\x1ee\x82O`CF=K\xeb$I"
1677 b"\x17_\xefX\x8bJ'v\xde\x1f+\xd9.v\xf8Tv\x17\xf2\x9f5\x19\xe1\xb9\x91\xa8S"
1678 b"\x86\xbd\x1a\"(\xa5x\x8dC\x03X\x81\x91\xa8\x11\xc4pS\x13\xbc\xf2'J\xae!"
1679 b"\xef\xef\x84G\t\x8d\xc4\x10\x132\x00oS\x9e\xe0\xe4d\x8f\xb8y\xac\xa6\x9f"
1680 b",\xb8f\x87\r\xdf\x9eE\x0f\xe1\xd0\\L\x00\xb2\xe1h\x84\xef}\x98\xa8\x11"
1681 b"\xccW#\\\x83\x7fo\xbbz\x8f\x00"
1682)
1683
1684FILTERS_RAW_3 = [{"id": lzma.FILTER_IA64, "start_offset": 0x100},
1685 {"id": lzma.FILTER_LZMA2}]
1686COMPRESSED_RAW_3 = (
1687 b"\xe0\x07\x80\x03\xdf]\x00\x05\x14\x07bX\x19\xcd\xddn\x98\x15\xe4\xb4\x9d"
1688 b"o\x1d\xc4\xe5\n\x03\xcc2h\xc7\\\x86\xff\xf8\xe2\xfc\xe7\xd9\xfe6\xb8("
1689 b"\xa8wd\xc2\"u.n\x1e\xc3\xf2\x8e\x8d\x8f\x02\x17/\xa6=\xf0\xa2\xdf/M\x89"
1690 b"\xbe\xde\xa7\x1cz\x18-]\xd5\xef\x13\x8frZ\x15\x80\x8c\xf8\x8do\xfa\x12"
1691 b"\x9b#z/\xef\xf0\xfaF\x01\x82\xa3M\x8e\xa1t\xca6 BF$\xe5Q\xa4\x98\xee\xde"
1692 b"l\xe8\x7f\xf0\x9d,bn\x0b\x13\xd4\xa8\x81\xe4N\xc8\x86\x153\xf5x2\xa2O"
1693 b"\x13@Q\xa1\x00/\xa5\xd0O\x97\xdco\xae\xf7z\xc4\xcdS\xb6t<\x16\xf2\x9cI#"
1694 b"\x89ud\xc66Y\xd9\xee\xe6\xce\x12]\xe5\xf0\xaa\x96-Pe\xade:\x04\t\x1b\xf7"
1695 b"\xdb7\n\x86\x1fp\xc8J\xba\xf4\xf0V\xa9\xdc\xf0\x02%G\xf9\xdf=?\x15\x1b"
1696 b"\xe1(\xce\x82=\xd6I\xac3\x12\x0cR\xb7\xae\r\xb1i\x03\x95\x01\xbd\xbe\xfa"
1697 b"\x02s\x01P\x9d\x96X\xb12j\xc8L\xa8\x84b\xf6\xc3\xd4c-H\x93oJl\xd0iQ\xe4k"
1698 b"\x84\x0b\xc1\xb7\xbc\xb1\x17\x88\xb1\xca?@\xf6\x07\xea\xe6x\xf1H12P\x0f"
1699 b"\x8a\xc9\xeauw\xe3\xbe\xaai\xa9W\xd0\x80\xcd#cb5\x99\xd8]\xa9d\x0c\xbd"
1700 b"\xa2\xdcWl\xedUG\xbf\x89yF\xf77\x81v\xbd5\x98\xbeh8\x18W\x08\xf0\x1b\x99"
1701 b"5:\x1a?rD\x96\xa1\x04\x0f\xae\xba\x85\xeb\x9d5@\xf5\x83\xd37\x83\x8ac"
1702 b"\x06\xd4\x97i\xcdt\x16S\x82k\xf6K\x01vy\x88\x91\x9b6T\xdae\r\xfd]:k\xbal"
1703 b"\xa9\xbba\xc34\xf9r\xeb}r\xdb\xc7\xdb*\x8f\x03z\xdc8h\xcc\xc9\xd3\xbcl"
1704 b"\xa5-\xcb\xeaK\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xac_\x85\x8d\xe7\xc1@\x9c\xecqc\xa3#\xad\xf1"
1719 b"\x935\xb5)_\r\xec3]\x0fo]5\xd0my\x07\x9b\xee\x81\xb5\x0f\xcfK+\x00\xc0"
1720 b"\xe4b\x10\xe4\x0c\x1a \x9b\xe0\x97t\xf6\xa1\x9e\x850\xba\x0c\x9a\x8d\xc8"
1721 b"\x8f\x07\xd7\xae\xc8\xf9+i\xdc\xb9k\xb0>f\x19\xb8\r\xa8\xf8\x1f$\xa5{p"
1722 b"\xc6\x880\xce\xdb\xcf\xca_\x86\xac\x88h6\x8bZ%'\xd0\n\xbf\x0f\x9c\"\xba"
1723 b"\xe5\x86\x9f\x0f7X=mNX[\xcc\x19FU\xc9\x860\xbc\x90a+* \xae_$\x03\x1e\xd3"
1724 b"\xcd_\xa0\x9c\xde\xaf46q\xa5\xc9\x92\xd7\xca\xe3`\x9d\x85}\xb4\xff\xb3"
1725 b"\x83\xfb\xb6\xca\xae`\x0bw\x7f\xfc\xd8\xacVe\x19\xc8\x17\x0bZ\xad\x88"
1726 b"\xeb#\x97\x03\x13\xb1d\x0f{\x0c\x04w\x07\r\x97\xbd\xd6\xc1\xc3B:\x95\x08"
1727 b"^\x10V\xaeaH\x02\xd9\xe3\n\\\x01X\xf6\x9c\x8a\x06u#%\xbe*\xa1\x18v\x85"
1728 b"\xec!\t4\x00\x00\x00"
1729)
1730
1731FILTERS_RAW_4 = [{"id": lzma.FILTER_DELTA, "dist": 4},
1732 {"id": lzma.FILTER_X86, "start_offset": 0x40},
1733 {"id": lzma.FILTER_LZMA2, "preset": 4, "lc": 2}]
1734COMPRESSED_RAW_4 = (
1735 b"\xe0\x07\x80\x06\x0e\\\x00\x05\x14\x07bW\xaah\xdd\x10\xdc'\xd6\x90,\xc6v"
1736 b"Jq \x14l\xb7\x83xB\x0b\x97f=&fx\xba\n>Tn\xbf\x8f\xfb\x1dF\xca\xc3v_\xca?"
1737 b"\xfbV<\x92#\xd4w\xa6\x8a\xeb\xf6\x03\xc0\x01\x94\xd8\x9e\x13\x12\x98\xd1"
1738 b"*\xfa]c\xe8\x1e~\xaf\xb5]Eg\xfb\x9e\x01\"8\xb2\x90\x06=~\xe9\x91W\xcd"
1739 b"\xecD\x12\xc7\xfa\xe1\x91\x06\xc7\x99\xb9\xe3\x901\x87\x19u\x0f\x869\xff"
1740 b"\xc1\xb0hw|\xb0\xdcl\xcck\xb16o7\x85\xee{Y_b\xbf\xbc$\xf3=\x8d\x8bw\xe5Z"
1741 b"\x08@\xc4kmE\xad\xfb\xf6*\xd8\xad\xa1\xfb\xc5{\xdej,)\x1emB\x1f<\xaeca"
1742 b"\x80(\xee\x07 \xdf\xe9\xf8\xeb\x0e-\x97\x86\x90c\xf9\xea'B\xf7`\xd7\xb0"
1743 b"\x92\xbd\xa0\x82]\xbd\x0e\x0eB\x19\xdc\x96\xc6\x19\xd86D\xf0\xd5\x831"
1744 b"\x03\xb7\x1c\xf7&5\x1a\x8f PZ&j\xf8\x98\x1bo\xcc\x86\x9bS\xd3\xa5\xcdu"
1745 b"\xf9$\xcc\x97o\xe5V~\xfb\x97\xb5\x0b\x17\x9c\xfdxW\x10\xfep4\x80\xdaHDY"
1746 b"\xfa)\xfet\xb5\"\xd4\xd3F\x81\xf4\x13\x1f\xec\xdf\xa5\x13\xfc\"\x91x\xb7"
1747 b"\x99\xce\xc8\x92\n\xeb[\x10l*Y\xd8\xb1@\x06\xc8o\x8d7r\xebu\xfd5\x0e\x7f"
1748 b"\xf1$U{\t}\x1fQ\xcfxN\x9d\x9fXX\xe9`\x83\xc1\x06\xf4\x87v-f\x11\xdb/\\"
1749 b"\x06\xff\xd7)B\xf3g\x06\x88#2\x1eB244\x7f4q\t\xc893?mPX\x95\xa6a\xfb)d"
1750 b"\x9b\xfc\x98\x9aj\x04\xae\x9b\x9d\x19w\xba\xf92\xfaA\x11\\\x17\x97C3\xa4"
1751 b"\xbc!\x88\xcdo[\xec:\x030\x91.\x85\xe0@\\4\x16\x12\x9d\xcaJv\x97\xb04"
1752 b"\xack\xcbkf\xa3ss\xfc\x16^\x8ce\x85a\xa5=&\xecr\xb3p\xd1E\xd5\x80y\xc7"
1753 b"\xda\xf6\xfek\xbcT\xbfH\xee\x15o\xc5\x8c\x830\xec\x1d\x01\xae\x0c-e\\"
1754 b"\x91\x90\x94\xb2\xf8\x88\x91\xe8\x0b\xae\xa7>\x98\xf6\x9ck\xd2\xc6\x08"
1755 b"\xe6\xab\t\x98\xf2!\xa0\x8c^\xacqA\x99<\x1cEG\x97\xc8\xf1\xb6\xb9\x82"
1756 b"\x8d\xf7\x08s\x98a\xff\xe3\xcc\x92\x0e\xd2\xb6U\xd7\xd9\x86\x7fa\xe5\x1c"
1757 b"\x8dTG@\t\x1e\x0e7*\xfc\xde\xbc]6N\xf7\xf1\x84\x9e\x9f\xcf\xe9\x1e\xb5'"
1758 b"\xf4<\xdf\x99sq\xd0\x9d\xbd\x99\x0b\xb4%p4\xbf{\xbb\x8a\xd2\x0b\xbc=M"
1759 b"\x94H:\xf5\xa8\xd6\xa4\xc90\xc2D\xb9\xd3\xa8\xb0S\x87 `\xa2\xeb\xf3W\xce"
1760 b" 7\xf9N#\r\xe6\xbe\t\x9d\xe7\x811\xf9\x10\xc1\xc2\x14\xf6\xfc\xcba\xb7"
1761 b"\xb1\x7f\x95l\xe4\tjA\xec:\x10\xe5\xfe\xc2\\=D\xe2\x0c\x0b3]\xf7\xc1\xf7"
1762 b"\xbceZ\xb1A\xea\x16\xe5\xfddgFQ\xed\xaf\x04\xa3\xd3\xf8\xa2q\x19B\xd4r"
1763 b"\xc5\x0c\x9a\x14\x94\xea\x91\xc4o\xe4\xbb\xb4\x99\xf4@\xd1\xe6\x0c\xe3"
1764 b"\xc6d\xa0Q\n\xf2/\xd8\xb8S5\x8a\x18:\xb5g\xac\x95D\xce\x17\x07\xd4z\xda"
1765 b"\x90\xe65\x07\x19H!\t\xfdu\x16\x8e\x0eR\x19\xf4\x8cl\x0c\xf9Q\xf1\x80"
1766 b"\xe3\xbf\xd7O\xf8\x8c\x18\x0b\x9c\xf1\x1fb\xe1\tR\xb2\xf1\xe1A\xea \xcf-"
1767 b"IGE\xf1\x14\x98$\x83\x15\xc9\xd8j\xbf\x19\x0f\xd5\xd1\xaa\xb3\xf3\xa5I2s"
1768 b"\x8d\x145\xca\xd5\xd93\x9c\xb8D0\xe6\xaa%\xd0\xc0P}JO^h\x8e\x08\xadlV."
1769 b"\x18\x88\x13\x05o\xb0\x07\xeaw\xe0\xb6\xa4\xd5*\xe4r\xef\x07G+\xc1\xbei["
1770 b"w\xe8\xab@_\xef\x15y\xe5\x12\xc9W\x1b.\xad\x85-\xc2\xf7\xe3mU6g\x8eSA"
1771 b"\x01(\xd3\xdb\x16\x13=\xde\x92\xf9,D\xb8\x8a\xb2\xb4\xc9\xc3\xefnE\xe8\\"
1772 b"\xa6\xe2Y\xd2\xcf\xcb\x8c\xb6\xd5\xe9\x1d\x1e\x9a\x8b~\xe2\xa6\rE\x84uV"
1773 b"\xed\xc6\x99\xddm<\x10[\x0fu\x1f\xc1\x1d1\n\xcfw\xb2%!\xf0[\xce\x87\x83B"
1774 b"\x08\xaa,\x08%d\xcef\x94\"\xd9g.\xc83\xcbXY+4\xec\x85qA\n\x1d=9\xf0*\xb1"
1775 b"\x1f/\xf3s\xd61b\x7f@\xfb\x9d\xe3FQ\\\xbd\x82\x1e\x00\xf3\xce\xd3\xe1"
1776 b"\xca,E\xfd7[\xab\xb6\xb7\xac!mA}\xbd\x9d3R5\x9cF\xabH\xeb\x92)cc\x13\xd0"
1777 b"\xbd\xee\xe9n{\x1dIJB\xa5\xeb\x11\xe8`w&`\x8b}@Oxe\t\x8a\x07\x02\x95\xf2"
1778 b"\xed\xda|\xb1e\xbe\xaa\xbbg\x19@\xe1Y\x878\x84\x0f\x8c\xe3\xc98\xf2\x9e"
1779 b"\xd5N\xb5J\xef\xab!\xe2\x8dq\xe1\xe5q\xc5\xee\x11W\xb7\xe4k*\x027\xa0"
1780 b"\xa3J\xf4\xd8m\xd0q\x94\xcb\x07\n:\xb6`.\xe4\x9c\x15+\xc0)\xde\x80X\xd4"
1781 b"\xcfQm\x01\xc2cP\x1cA\x85'\xc9\xac\x8b\xe6\xb2)\xe6\x84t\x1c\x92\xe4Z"
1782 b"\x1cR\xb0\x9e\x96\xd1\xfb\x1c\xa6\x8b\xcb`\x10\x12]\xf2gR\x9bFT\xe0\xc8H"
1783 b"S\xfb\xac<\x04\xc7\xc1\xe8\xedP\xf4\x16\xdb\xc0\xd7e\xc2\x17J^\x1f\xab"
1784 b"\xff[\x08\x19\xb4\xf5\xfb\x19\xb4\x04\xe5c~']\xcb\xc2A\xec\x90\xd0\xed"
1785 b"\x06,\xc5K{\x86\x03\xb1\xcdMx\xdeQ\x8c3\xf9\x8a\xea=\x89\xaba\xd2\xc89a"
1786 b"\xd72\xf0\xc3\x19\x8a\xdfs\xd4\xfd\xbb\x81b\xeaE\"\xd8\xf4d\x0cD\xf7IJ!"
1787 b"\xe5d\xbbG\xe9\xcam\xaa\x0f_r\x95\x91NBq\xcaP\xce\xa7\xa9\xb5\x10\x94eP!"
1788 b"|\x856\xcd\xbfIir\xb8e\x9bjP\x97q\xabwS7\x1a\x0ehM\xe7\xca\x86?\xdeP}y~"
1789 b"\x0f\x95I\xfc\x13\xe1<Q\x1b\x868\x1d\x11\xdf\x94\xf4\x82>r\xa9k\x88\xcb"
1790 b"\xfd\xc3v\xe2\xb9\x8a\x02\x8eq\x92I\xf8\xf6\xf1\x03s\x9b\xb8\xe3\"\xe3"
1791 b"\xa9\xa5>D\xb8\x96;\xe7\x92\xd133\xe8\xdd'e\xc9.\xdc;\x17\x1f\xf5H\x13q"
1792 b"\xa4W\x0c\xdb~\x98\x01\xeb\xdf\xe32\x13\x0f\xddx\n6\xa0\t\x10\xb6\xbb"
1793 b"\xb0\xc3\x18\xb6;\x9fj[\xd9\xd5\xc9\x06\x8a\x87\xcd\xe5\xee\xfc\x9c-%@"
1794 b"\xee\xe0\xeb\xd2\xe3\xe8\xfb\xc0\x122\\\xc7\xaf\xc2\xa1Oth\xb3\x8f\x82"
1795 b"\xb3\x18\xa8\x07\xd5\xee_\xbe\xe0\x1cA\x1e_\r\x9a\xb0\x17W&\xa2D\x91\x94"
1796 b"\x1a\xb2\xef\xf2\xdc\x85;X\xb0,\xeb>-7S\xe5\xca\x07)\x1fp\x7f\xcaQBL\xca"
1797 b"\xf3\xb9d\xfc\xb5su\xb0\xc8\x95\x90\xeb*)\xa0v\xe4\x9a{FW\xf4l\xde\xcdj"
1798 b"\x00"
1799)
1800
animalize4ffd05d2019-09-12 22:20:37 +08001801ISSUE_21872_DAT = (
1802 b']\x00\x00@\x00h3\x00\x00\x00\x00\x00\x00\x00\x00`D\x0c\x99\xc8'
1803 b'\xd1\xbbZ^\xc43+\x83\xcd\xf1\xc6g\xec-\x061F\xb1\xbb\xc7\x17%-\xea'
1804 b'\xfap\xfb\x8fs\x128\xb2,\x88\xe4\xc0\x12|*x\xd0\xa2\xc4b\x1b!\x02c'
1805 b'\xab\xd9\x87U\xb8n \xfaVJ\x9a"\xb78\xff%_\x17`?@*\xc2\x82'
1806 b"\xf2^\x1b\xb8\x04&\xc0\xbb\x03g\x9d\xca\xe9\xa4\xc9\xaf'\xe5\x8e}"
1807 b'F\xdd\x11\xf3\x86\xbe\x1fN\x95\\\xef\xa2Mz-\xcb\x9a\xe3O@'
1808 b"\x19\x07\xf6\xee\x9e\x9ag\xc6\xa5w\rnG'\x99\xfd\xfeGI\xb0"
1809 b'\xbb\xf9\xc2\xe1\xff\xc5r\xcf\x85y[\x01\xa1\xbd\xcc/\xa3\x1b\x83\xaa'
1810 b'\xc6\xf9\x99\x0c\xb6_\xc9MQ+x\xa2F\xda]\xdd\xe8\xfb\x1a&'
1811 b',\xc4\x19\x1df\x81\x1e\x90\xf3\xb8Hgr\x85v\xbe\xa3qx\x01Y\xb5\x9fF'
1812 b"\x13\x18\x01\xe69\x9b\xc8'\x1e\x9d\xd6\xe4F\x84\xac\xf8d<\x11\xd5"
1813 b'\\\x0b\xeb\x0e\x82\xab\xb1\xe6\x1fka\xe1i\xc4 C\xb1"4)\xd6\xa7`\x02'
1814 b'\xec\x11\x8c\xf0\x14\xb0\x1d\x1c\xecy\xf0\xb7|\x11j\x85X\xb2!\x1c'
1815 b'\xac\xb5N\xc7\x85j\x9ev\xf5\xe6\x0b\xc1]c\xc15\x16\x9f\xd5\x99'
1816 b"\xfei^\xd2G\x9b\xbdl\xab:\xbe,\xa9'4\x82\xe5\xee\xb3\xc1"
1817 b'$\x93\x95\xa8Y\x16\xf5\xbf\xacw\x91\x04\x1d\x18\x06\xe9\xc5\xfdk\x06'
1818 b'\xe8\xfck\xc5\x86>\x8b~\xa4\xcb\xf1\xb3\x04\xf1\x04G5\xe2\xcc]'
1819 b'\x16\xbf\x140d\x18\xe2\xedw#(3\xca\xa1\x80bX\x7f\xb3\x84'
1820 b'\x9d\xdb\xe7\x08\x97\xcd\x16\xb9\xf1\xd5r+m\x1e\xcb3q\xc5\x9e\x92'
1821 b"\x7f\x8e*\xc7\xde\xe9\xe26\xcds\xb1\x10-\xf6r\x02?\x9d\xddCgJN'"
1822 b'\x11M\xfa\nQ\n\xe6`m\xb8N\xbbq\x8el\x0b\x02\xc7:q\x04G\xa1T'
1823 b'\xf1\xfe!0\x85~\xe5\x884\xe9\x89\xfb\x13J8\x15\xe42\xb6\xad'
1824 b'\x877A\x9a\xa6\xbft]\xd0\xe35M\xb0\x0cK\xc8\xf6\x88\xae\xed\xa9,j7'
1825 b'\x81\x13\xa0(\xcb\xe1\xe9l2\x7f\xcd\xda\x95(\xa70B\xbd\xf4\xe3'
1826 b'hp\x94\xbdJ\xd7\t\xc7g\xffo?\x89?\xf8}\x7f\xbc\x1c\x87'
1827 b'\x14\xc0\xcf\x8cV:\x9a\x0e\xd0\xb2\x1ck\xffk\xb9\xe0=\xc7\x8d/'
1828 b'\xb8\xff\x7f\x1d\x87`\x19.\x98X*~\xa7j\xb9\x0b"\xf4\xe4;V`\xb9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xfc>'
1860 b'"\xd1v`\x82\xd5$\x89\xcf^\xd52.\xafd\xe8d@\xaa\xd5Y|\x90\x84'
1861 b'j\xdb}\x84riV\x8e\xf0X4rB\xf2NPS[\x8e\x88\xd4\x0fI\xb8'
1862 b'\xdd\xcb\x1d\xf2(\xdf;9\x9e|\xef^0;.*[\x9fl\x7f\xa2_X\xaff!\xbb\x03'
1863 b'\xff\x19\x8f\x88\xb5\xb6\x884\xa3\x05\xde3D{\xe3\xcb\xce\xe4t]'
1864 b'\x875\xe3Uf\xae\xea\x88\x1c\x03b\n\xb1,Q\xec\xcf\x08\t\xde@\x83\xaa<'
1865 b',-\xe4\xee\x9b\x843\xe5\x007\tK\xac\x057\xd6*X\xa3\xc6~\xba\xe6O'
1866 b'\x81kz"\xbe\xe43sL\xf1\xfa;\xf4^\x1e\xb4\x80\xe2\xbd\xaa\x17Z\xe1f'
1867 b'\xda\xa6\xb9\x07:]}\x9fa\x0b?\xba\xe7\xf15\x04M\xe3\n}M\xa4\xcb\r'
1868 b'2\x8a\x88\xa9\xa7\x92\x93\x84\x81Yo\x00\xcc\xc4\xab\x9aT\x96\x0b\xbe'
1869 b'U\xac\x1d\x8d\x1b\x98"\xf8\x8f\xf1u\xc1n\xcc\xfcA\xcc\x90\xb7i'
1870 b'\x83\x9c\x9c~\x1d4\xa2\xf0*J\xe7t\x12\xb4\xe3\xa0u\xd7\x95Z'
1871 b'\xf7\xafG\x96~ST,\xa7\rC\x06\xf4\xf0\xeb`2\x9e>Q\x0e\xf6\xf5\xc5'
1872 b'\x9b\xb5\xaf\xbe\xa3\x8f\xc0\xa3hu\x14\x12 \x97\x99\x04b\x8e\xc7\x1b'
1873 b'VKc\xc1\xf3 \xde\x85-:\xdc\x1f\xac\xce*\x06\xb3\x80;`'
1874 b'\xdb\xdd\x97\xfdg\xbf\xe7\xa8S\x08}\xf55e7\xb8/\xf0!\xc8'
1875 b"Y\xa8\x9a\x07'\xe2\xde\r\x02\xe1\xb2\x0c\xf4C\x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0co\x10\xcf\x18\x16\xa7\x1c'
1892 b"\xe5\x96\xa4\xd9\xe1\xa5v;]\xb7\xa9\xdc'hA\xe3\x9c&\x98\x0b9\xdf~@"
1893 b'\xf8\xact\x87<\xf94\x0c\x9d\x93\xb0)\xe1\xa2\x0f\x1e=:&\xd56\xa5A+'
1894 b'\xab\xc4\x00\x8d\x81\x93\xd4\xd8<\x82k\\d\xd8v\xab\xbd^l5C?\xd4\xa0'
1895 b'M\x12C\xc8\x80\r\xc83\xe8\xc0\xf5\xdf\xca\x05\xf4BPjy\xbe\x91\x9bzE'
1896 b"\xd8[\x93oT\r\x13\x16'\x1a\xbd*H\xd6\xfe\r\xf3\x91M\x8b\xee\x8f7f"
1897 b"\x0b;\xaa\x85\xf2\xdd'\x0fwM \xbd\x13\xb9\xe5\xb8\xb7 D+P\x1c\xe4g"
1898 b'n\xd2\xf1kc\x15\xaf\xc6\x90V\x03\xc2UovfZ\xcc\xd23^\xb3\xe7\xbf'
1899 b'\xacv\x1d\x82\xedx\xa3J\xa9\xb7\xcf\x0c\xe6j\x96n*o\x18>'
1900 b'\xc6\xfd\x97_+D{\x03\x15\xe8s\xb1\xc8HAG\xcf\xf4\x1a\xdd'
1901 b'\xad\x11\xbf\x157q+\xdeW\x89g"X\x82\xfd~\xf7\xab4\xf6`\xab\xf1q'
1902 b')\x82\x10K\xe9sV\xfe\xe45\xafs*\x14\xa7;\xac{\x06\x9d<@\x93G'
1903 b'j\x1d\xefL\xe9\xd8\x92\x19&\xa1\x16\x19\x04\tu5\x01]\xf6\xf4'
1904 b'\xcd\\\xd8A|I\xd4\xeb\x05\x88C\xc6e\xacQ\xe9*\x97~\x9au\xf8Xy'
1905 b"\x17P\x10\x9f\n\x8c\xe2fZEu>\x9b\x1e\x91\x0b'`\xbd\xc0\xa8\x86c\x1d"
1906 b'Z\xe2\xdc8j\x95\xffU\x90\x1e\xf4o\xbc\xe5\xe3e>\xd2R\xc0b#\xbc\x15'
1907 b'H-\xb9!\xde\x9d\x90k\xdew\x9b{\x99\xde\xf7/K)A\xfd\xf5\xe6:\xda'
1908 b'UM\xcc\xbb\xa2\x0b\x9a\x93\xf5{9\xc0 \xd2((6i\xc0\xbbu\xd8\x9e\x8d'
1909 b'\xf8\x04q\x10\xd4\x14\x9e7-\xb9B\xea\x01Q8\xc8v\x9a\x12A\x88Cd\x92'
1910 b"\x1c\x8c!\xf4\x94\x87'\xe3\xcd\xae\xf7\xd8\x93\xfa\xde\xa8b\x9e\xee2"
1911 b'K\xdb\x00l\x9d\t\xb1|D\x05U\xbb\xf4>\xf1w\x887\xd1}W\x9d|g|1\xb0\x13'
1912 b"\xa3 \xe5\xbfm@\xc06+\xb7\t\xcf\x15D\x9a \x1fM\x1f\xd2\xb5'\xa9\xbb"
1913 b'~Co\x82\xfa\xc2\t\xe6f\xfc\xbeI\xae1\x8e\xbe\xb8\xcf\x86\x17'
1914 b'\x9f\xe2`\xbd\xaf\xba\xb9\xbc\x1b\xa3\xcd\x82\x8fwc\xefd\xa9\xd5\x14'
1915 b'\xe2C\xafUE\xb6\x11MJH\xd0=\x05\xd4*I\xff"\r\x1b^\xcaS6=\xec@\xd5'
1916 b'\x11,\xe0\x87Gr\xaa[\xb8\xbc>n\xbd\x81\x0c\x07<\xe9\x92('
1917 b'\xb2\xff\xac}\xe7\xb6\x15\x90\x9f~4\x9a\xe6\xd6\xd8s\xed\x99tf'
1918 b'\xa0f\xf8\xf1\x87\t\x96/)\x85\xb6\n\xd7\xb2w\x0b\xbc\xba\x99\xee'
1919 b'Q\xeen\x1d\xad\x03\xc3s\xd1\xfd\xa2\xc6\xb7\x9a\x9c(G<6\xad[~H '
1920 b'\x16\x89\x89\xd0\xc3\xd2\xca~\xac\xea\xa5\xed\xe5\xfb\r:'
1921 b'\x8e\xa6\xf1e\xbb\xba\xbd\xe0(\xa3\x89_\x01(\xb5c\xcc\x9f\x1fg'
1922 b'v\xfd\x17\xb3\x08S=S\xee\xfc\x85>\x91\x8d\x8d\nYR\xb3G\xd1A\xa2\xb1'
1923 b'\xec\xb0\x01\xd2\xcd\xf9\xfe\x82\x06O\xb3\xecd\xa9c\xe0\x8eP\x90\xce'
1924 b'\xe0\xcd\xd8\xd8\xdc\x9f\xaa\x01"[Q~\xe4\x88\xa1#\xc1\x12C\xcf'
1925 b'\xbe\x80\x11H\xbf\x86\xd8\xbem\xcfWFQ(X\x01DK\xdfB\xaa\x10.-'
1926 b'\xd5\x9e|\x86\x15\x86N]\xc7Z\x17\xcd=\xd7)M\xde\x15\xa4LTi\xa0\x15'
1927 b'\xd1\xe7\xbdN\xa4?\xd1\xe7\x02\xfe4\xe4O\x89\x98&\x96\x0f\x02\x9c'
1928 b'\x9e\x19\xaa\x13u7\xbd0\xdc\xd8\x93\xf4BNE\x1d\x93\x82\x81\x16'
1929 b'\xe5y\xcf\x98D\xca\x9a\xe2\xfd\xcdL\xcc\xd1\xfc_\x0b\x1c\xa0]\xdc'
1930 b'\xa91 \xc9c\xd8\xbf\x97\xcfp\xe6\x19-\xad\xff\xcc\xd1N(\xe8'
1931 b'\xeb#\x182\x96I\xf7l\xf3r\x00'
1932)
1933
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001934
1935def test_main():
1936 run_unittest(
1937 CompressorDecompressorTestCase,
1938 CompressDecompressFunctionTestCase,
1939 FileTestCase,
Nadeem Vawdae8604042012-06-04 23:38:12 +02001940 OpenTestCase,
Nadeem Vawda3ff069e2011-11-30 00:25:06 +02001941 MiscellaneousTestCase,
1942 )
1943
1944if __name__ == "__main__":
1945 test_main()