From c97ee87d2e374c39944ae943c906978d2f182206 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Thu, 26 Oct 2017 23:23:29 +0200 Subject: test_compression: Fix mismatched suffixes --- tests/test_compression.py | 81 ++++++++++++++++++++++++++--------------------- 1 file 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): -- cgit v1.2.3