diff options
author | Michał Górny <mgorny@gentoo.org> | 2017-10-25 21:04:15 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2017-10-25 21:04:15 +0200 |
commit | 2c734223401e0cca9947794cc6a2676eada5f962 (patch) | |
tree | 0fae9f64a74d90b7fab4dd4a9be2cac13fc6f5a3 /tests/test_compression.py | |
parent | 193e60eb056851db7a5b9bfe017c504896250ab3 (diff) | |
download | gemato-2c734223401e0cca9947794cc6a2676eada5f962.tar.gz |
test_compression: Add tests for opening uncompressed files
Diffstat (limited to 'tests/test_compression.py')
-rw-r--r-- | tests/test_compression.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_compression.py b/tests/test_compression.py index 0870a1d..e0deaf3 100644 --- a/tests/test_compression.py +++ b/tests/test_compression.py @@ -328,3 +328,26 @@ dGhlIGxhenkgZG9nAADjZCTmHjHqggABLxeBCEmxH7bzfQEAAAAABFla self.assertEqual(xz.read(), TEST_STRING) except gemato.exceptions.UnsupportedCompression: raise unittest.SkipTest('xz compression unsupported') + + +class NoCompressionTest(unittest.TestCase): + """ + Tests for non-compressed data. + """ + + def test_open_potentially_compressed_path(self): + with tempfile.NamedTemporaryFile() as wf: + wf.write(TEST_STRING) + wf.flush() + + with gemato.compression.open_potentially_compressed_path( + wf.name, 'rb') as cf: + self.assertEqual(cf.read(), TEST_STRING) + + def test_open_potentially_compressed_path_write(self): + with tempfile.NamedTemporaryFile() as rf: + with gemato.compression.open_potentially_compressed_path( + rf.name, 'wb') as cf: + cf.write(TEST_STRING) + + self.assertEqual(rf.read(), TEST_STRING) |