summaryrefslogtreecommitdiff
path: root/tests/test_compression.py
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2017-10-26 23:23:29 +0200
committerMichał Górny <mgorny@gentoo.org>2017-10-26 23:35:53 +0200
commitc97ee87d2e374c39944ae943c906978d2f182206 (patch)
tree7cfb9e3104a7fb23b63a02b43a9eedab535218f6 /tests/test_compression.py
parentc3b591111ee7ae32eba4eae47dff95a5a338b942 (diff)
downloadgemato-c97ee87d2e374c39944ae943c906978d2f182206.tar.gz
test_compression: Fix mismatched suffixes
Diffstat (limited to 'tests/test_compression.py')
-rw-r--r--tests/test_compression.py81
1 files changed, 45 insertions, 36 deletions
diff --git a/tests/test_compression.py b/tests/test_compression.py
index 1c1ff68..cdb8c59 100644
--- a/tests/test_compression.py
+++ b/tests/test_compression.py
@@ -236,18 +236,21 @@ OxleaA==
raise unittest.SkipTest('bz2 compression unsupported')
def test_open_potentially_compressed_path_fileno_passthrough(self):
- with tempfile.NamedTemporaryFile(suffix='.gz') as rf:
- fs1 = gemato.compression.open_potentially_compressed_path(
- rf.name, 'w', encoding='utf_16_be')
- with fs1 as cf:
- self.assertListEqual([f.fileno() for f in fs1.files],
- [cf.fileno() for f in fs1.files])
-
- fs2 = gemato.compression.open_potentially_compressed_path(
- rf.name, 'r', encoding='utf_16_be')
- with fs2 as cf:
- self.assertListEqual([f.fileno() for f in fs2.files],
- [cf.fileno() for f in fs2.files])
+ with tempfile.NamedTemporaryFile(suffix='.bz2') as rf:
+ try:
+ fs1 = gemato.compression.open_potentially_compressed_path(
+ rf.name, 'w', encoding='utf_16_be')
+ with fs1 as cf:
+ self.assertListEqual([f.fileno() for f in fs1.files],
+ [cf.fileno() for f in fs1.files])
+
+ fs2 = gemato.compression.open_potentially_compressed_path(
+ rf.name, 'r', encoding='utf_16_be')
+ with fs2 as cf:
+ self.assertListEqual([f.fileno() for f in fs2.files],
+ [cf.fileno() for f in fs2.files])
+ except gemato.exceptions.UnsupportedCompression:
+ raise unittest.SkipTest('bz2 compression unsupported')
class LZMALegacyCompressionTest(unittest.TestCase):
@@ -378,18 +381,21 @@ ADUdSd6zBOkOpekGFH46zix9wE9VT65OVeV479//7uUAAA==
raise unittest.SkipTest('lzma compression unsupported')
def test_open_potentially_compressed_path_fileno_passthrough(self):
- with tempfile.NamedTemporaryFile(suffix='.gz') as rf:
- fs1 = gemato.compression.open_potentially_compressed_path(
- rf.name, 'w', encoding='utf_16_be')
- with fs1 as cf:
- self.assertListEqual([f.fileno() for f in fs1.files],
- [cf.fileno() for f in fs1.files])
-
- fs2 = gemato.compression.open_potentially_compressed_path(
- rf.name, 'r', encoding='utf_16_be')
- with fs2 as cf:
- self.assertListEqual([f.fileno() for f in fs2.files],
- [cf.fileno() for f in fs2.files])
+ with tempfile.NamedTemporaryFile(suffix='.lzma') as rf:
+ try:
+ fs1 = gemato.compression.open_potentially_compressed_path(
+ rf.name, 'w', encoding='utf_16_be')
+ with fs1 as cf:
+ self.assertListEqual([f.fileno() for f in fs1.files],
+ [cf.fileno() for f in fs1.files])
+
+ fs2 = gemato.compression.open_potentially_compressed_path(
+ rf.name, 'r', encoding='utf_16_be')
+ with fs2 as cf:
+ self.assertListEqual([f.fileno() for f in fs2.files],
+ [cf.fileno() for f in fs2.files])
+ except gemato.exceptions.UnsupportedCompression:
+ raise unittest.SkipTest('lzma compression unsupported')
class XZCompressionTest(unittest.TestCase):
@@ -521,18 +527,21 @@ dGhlIGxhenkgZG9nAADjZCTmHjHqggABLxeBCEmxH7bzfQEAAAAABFla
raise unittest.SkipTest('xz compression unsupported')
def test_open_potentially_compressed_path_fileno_passthrough(self):
- with tempfile.NamedTemporaryFile(suffix='.gz') as rf:
- fs1 = gemato.compression.open_potentially_compressed_path(
- rf.name, 'w', encoding='utf_16_be')
- with fs1 as cf:
- self.assertListEqual([f.fileno() for f in fs1.files],
- [cf.fileno() for f in fs1.files])
-
- fs2 = gemato.compression.open_potentially_compressed_path(
- rf.name, 'r', encoding='utf_16_be')
- with fs2 as cf:
- self.assertListEqual([f.fileno() for f in fs2.files],
- [cf.fileno() for f in fs2.files])
+ with tempfile.NamedTemporaryFile(suffix='.xz') as rf:
+ try:
+ fs1 = gemato.compression.open_potentially_compressed_path(
+ rf.name, 'w', encoding='utf_16_be')
+ with fs1 as cf:
+ self.assertListEqual([f.fileno() for f in fs1.files],
+ [cf.fileno() for f in fs1.files])
+
+ fs2 = gemato.compression.open_potentially_compressed_path(
+ rf.name, 'r', encoding='utf_16_be')
+ with fs2 as cf:
+ self.assertListEqual([f.fileno() for f in fs2.files],
+ [cf.fileno() for f in fs2.files])
+ except gemato.exceptions.UnsupportedCompression:
+ raise unittest.SkipTest('xz compression unsupported')
class NoCompressionTest(unittest.TestCase):