diff --git a/tests/test_mime.py b/tests/test_mime.py index 440d6a1..ef35722 100644 --- a/tests/test_mime.py +++ b/tests/test_mime.py @@ -24,7 +24,9 @@ class TestMime (unittest.TestCase): def mime_test (self, filename, mime, encoding): """Test that file has given mime and encoding.""" archive = os.path.join(datadir, filename) - self.assertEqual(patoolib.util.guess_mime(filename), (mime, encoding)) + res = patoolib.util.guess_mime(archive) + fail_msg = "MIME type for archive `%s' should be (%s, %s), but was %s" % (filename, mime, encoding, res) + self.assertEqual(res, (mime, encoding), fail_msg) @needs_program('file') def test_mime (self): @@ -42,10 +44,11 @@ class TestMime (unittest.TestCase): self.mime_test("t.deb.foo", "application/x-debian-package", None) self.mime_test("t.gz", "application/x-gzip", None) self.mime_test("t.gz.foo", "application/x-gzip", None) - self.mime_test("t.jar", "application/java-archive", None) - self.mime_test("t.jar.foo", "application/java-archive", None) + self.mime_test("t.jar", "application/zip", None) + self.mime_test("t.jar.foo", "application/zip", None) self.mime_test("t.lzma", "application/x-lzma", None) - self.mime_test("t.lzma.foo", "application/x-lzma", None) + # file(1) does not recognize .lzma files + #self.mime_test("t.lzma.foo", "application/x-lzma", None) self.mime_test("t.lzo", "application/x-lzop", None) self.mime_test("t.lzo.foo", "application/x-lzop", None) self.mime_test("t.rar", "application/x-rar", None) @@ -55,21 +58,22 @@ class TestMime (unittest.TestCase): self.mime_test("t.tar", "application/x-tar", None) self.mime_test("t.tar.foo", "application/x-tar", None) self.mime_test("t.tar.bz2", "application/x-tar", "bzip2") - self.mime_test("t.tar.bz2.foo", "application/x-bzip2", None) + self.mime_test("t.tar.bz2.foo", "application/x-tar", "bzip2") self.mime_test("t.tar.gz", "application/x-tar", "gzip") - self.mime_test("t.tar.gz.foo", "application/x-gzip", None) + self.mime_test("t.tar.gz.foo", "application/x-tar", "gzip") self.mime_test("t.tar.lzma", "application/x-tar", "lzma") - self.mime_test("t.tar.lzma.foo", "application/x-lzma", None) + # file(1) does not recognize .lzma files + #self.mime_test("t.tar.lzma.foo", "application/x-tar", "lzma") self.mime_test("t.tar.xz", "application/x-tar", "xz") - self.mime_test("t.tar.xz.foo", "application/x-xz", None) + self.mime_test("t.tar.xz.foo", "application/x-tar", "xz") self.mime_test("t.tar.Z", "application/x-tar", "compress") - self.mime_test("t.tar.Z.foo", "application/x-compress", None) + self.mime_test("t.tar.Z.foo", "application/x-tar", "compress") self.mime_test("t.taz", "application/x-tar", "compress") - self.mime_test("t.taz.foo", "application/x-compress", None) + self.mime_test("t.taz.foo", "application/x-tar", "compress") self.mime_test("t.tbz2", "application/x-tar", "bzip2") - self.mime_test("t.tbz2.foo", "application/x-bzip2", None) + self.mime_test("t.tbz2.foo", "application/x-tar", "bzip2") self.mime_test("t.tgz", "application/x-tar", "gzip") - self.mime_test("t.tgz.foo", "application/x-gzip", None) + self.mime_test("t.tgz.foo", "application/x-tar", "gzip") self.mime_test("t.txt.gz", "application/x-gzip", None) self.mime_test("t.txt.gz.foo", "application/x-gzip", None) self.mime_test("t.xz", "application/x-xz", None)