summaryrefslogtreecommitdiff
path: root/tests/test_compression.py
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2017-10-25 20:46:12 +0200
committerMichał Górny <mgorny@gentoo.org>2017-10-25 20:46:12 +0200
commit85b27b59a5e9014f838f5ddc6dcb94424f78aaee (patch)
tree173221b8139e252c6e2d6364b0fd582e7f9e5bfe /tests/test_compression.py
parentf93df723eeec064dd8b5bb92a7926be49ab19bed (diff)
downloadgemato-85b27b59a5e9014f838f5ddc6dcb94424f78aaee.tar.gz
compression: Enforce correct format for lzma/xz files
Diffstat (limited to 'tests/test_compression.py')
-rw-r--r--tests/test_compression.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_compression.py b/tests/test_compression.py
index 6f443cc..a81e80f 100644
--- a/tests/test_compression.py
+++ b/tests/test_compression.py
@@ -160,6 +160,18 @@ ADUdSd6zBOkOpekGFH46zix9wE9VT65OVeV479//7uUAAA==
except gemato.exceptions.UnsupportedCompression:
raise unittest.SkipTest('lzma compression unsupported')
+ def test_lzma_legacy_as_xz(self):
+ """
+ Test that the class rejects mislabel files.
+ """
+ if gemato.compression.lzma is None:
+ raise unittest.SkipTest('xz compression unsupported')
+
+ with io.BytesIO(base64.b64decode(self.BASE64)) as f:
+ with self.assertRaises(gemato.compression.lzma.LZMAError):
+ with gemato.compression.open_compressed_file('xz', f, "rb") as xz:
+ xz.read()
+
class XZCompressionTest(unittest.TestCase):
BASE64 = b'''
@@ -213,3 +225,15 @@ dGhlIGxhenkgZG9nAADjZCTmHjHqggABLxeBCEmxH7bzfQEAAAAABFla
self.assertEqual(xz.read(), TEST_STRING)
except gemato.exceptions.UnsupportedCompression:
raise unittest.SkipTest('xz compression unsupported')
+
+ def test_xz_as_lzma_legacy(self):
+ """
+ Test that the class rejects mislabel files.
+ """
+ if gemato.compression.lzma is None:
+ raise unittest.SkipTest('xz compression unsupported')
+
+ with io.BytesIO(base64.b64decode(self.BASE64)) as f:
+ with self.assertRaises(gemato.compression.lzma.LZMAError):
+ with gemato.compression.open_compressed_file('lzma', f, "rb") as lzma:
+ lzma.read()