Add tests for nested compression

Why:

* To ensure we don't try and unrar a rar.gz file.

This change addresses the need by:

* Adds test file archive.rar.gz
* Add mime check to ensure we get the mime of gzip, not rar.
This commit is contained in:
Charles LeDoux 2017-12-27 18:20:46 -06:00 committed by Yaroslav Halchenko
parent 03018b4e5b
commit eadc156170
3 changed files with 6 additions and 0 deletions

BIN
tests/data/t.rar.gz Normal file

Binary file not shown.

BIN
tests/data/t.rar.gz.foo Normal file

Binary file not shown.

View File

@ -150,6 +150,12 @@ class TestMime (unittest.TestCase):
self.mime_test_file("t.tar.bz2.foo", "application/x-tar", "bzip2") self.mime_test_file("t.tar.bz2.foo", "application/x-tar", "bzip2")
self.mime_test_file("t.tbz2.foo", "application/x-tar", "bzip2") self.mime_test_file("t.tbz2.foo", "application/x-tar", "bzip2")
@needs_program('file')
def test_nested_gzip (self):
# Ensure that a file that doesn't natively support encoding does not see the encoding
self.mime_test_file("t.rar.gz", "application/gzip")
self.mime_test_file("t.rar.gz.foo", "application/gzip")
@needs_program('file') @needs_program('file')
@needs_program('gzip') @needs_program('gzip')
def test_mime_file_gzip (self): def test_mime_file_gzip (self):