diff options
author | Michał Górny <mgorny@gentoo.org> | 2017-10-25 22:43:02 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2017-10-25 22:43:02 +0200 |
commit | 013e7a5bf896e3a1626bf40eebfd790821e94cf2 (patch) | |
tree | 15e31532338a9975094c662a71bf9a13061f0b2a /tests/test_compression.py | |
parent | bd4491d09b69159c89b53fe930f4b4339a1dc042 (diff) | |
download | gemato-013e7a5bf896e3a1626bf40eebfd790821e94cf2.tar.gz |
test_compression: Check if .fileno() is passed through correctly
Diffstat (limited to 'tests/test_compression.py')
-rw-r--r-- | tests/test_compression.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/test_compression.py b/tests/test_compression.py index 97b319a..13c7835 100644 --- a/tests/test_compression.py +++ b/tests/test_compression.py @@ -93,6 +93,20 @@ L0stUijJSFXISayqVEjJTwcAlGd4GBcAAAA= with gemato.compression.open_compressed_file('gz', rf, 'rb') as gz: self.assertEqual(gz.read(), UTF16_TEST_STRING) + 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]) + class Bzip2CompressionTest(unittest.TestCase): BASE64 = b''' @@ -196,6 +210,20 @@ OxleaA== except gemato.exceptions.UnsupportedCompression: 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]) + class LZMALegacyCompressionTest(unittest.TestCase): BASE64 = b''' @@ -310,6 +338,20 @@ ADUdSd6zBOkOpekGFH46zix9wE9VT65OVeV479//7uUAAA== except gemato.exceptions.UnsupportedCompression: 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]) + class XZCompressionTest(unittest.TestCase): BASE64 = b''' @@ -400,6 +442,20 @@ dGhlIGxhenkgZG9nAADjZCTmHjHqggABLxeBCEmxH7bzfQEAAAAABFla except gemato.exceptions.UnsupportedCompression: 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]) + class NoCompressionTest(unittest.TestCase): """ |