diff options
author | Thomas Kluyver <takowl@gmail.com> | 2013-03-11 16:52:04 +0000 |
---|---|---|
committer | Thomas Kluyver <takowl@gmail.com> | 2013-03-11 16:52:04 +0000 |
commit | f7bf880ea1cc7876578613218dc139d964c38543 (patch) | |
tree | ef64b9490dd2fe90d63b8c5ea03ca26ca79084fb /test | |
parent | d834e48ad1a5be42db8dd1d6a28302f344ac19c1 (diff) |
More tests for xdg.Mime
Diffstat (limited to 'test')
-rw-r--r-- | test/resources.py | 4 | ||||
-rw-r--r-- | test/test-mime.py | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/test/resources.py b/test/resources.py index da9df1f..7df387a 100644 --- a/test/resources.py +++ b/test/resources.py @@ -468,8 +468,10 @@ mime_magic_db = b"""MIME-Magic\0 [10:application/madeup] >0=\0\x05ab cd +>10=\0\x05ab de&\xff\xff +\xff\xff [10:application/imaginary] ->0=\0\x03abc¬unhandled_future_field +>0=\0\x03abc@unhandled_future_field """ png_data = b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15\xc4\x89\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x00\rIDAT\x08\x99c\xf8\x7f\x83\xe1?\x00\x07\x88\x02\xd7\xd9\n\xd8\xdc\x00\x00\x00\x00IEND\xaeB`\x82' diff --git a/test/test-mime.py b/test/test-mime.py index 5557db7..f679e4e 100644 --- a/test/test-mime.py +++ b/test/test-mime.py @@ -142,7 +142,8 @@ class MagicDBTest(MimeTestBase): # Test that a newline within the value doesn't break parsing. prio, madeup = self.magic.bytype[Mime.lookup('application', 'madeup')] - self.assertEqual(madeup.value, b'ab\ncd') + self.assertEqual(madeup.rules[0].value, b'ab\ncd') + self.assertEqual(madeup.rules[1].mask, b'\xff\xff\n\xff\xff') def test_match_data(self): res = self.magic.match_data(resources.png_data) @@ -157,6 +158,11 @@ class MagicDBTest(MimeTestBase): res = self.magic.match_data(b'oiejgoethetrkjgnwefergoijekngjekg') assert res is None, res + def test_match_nested(self): + data = b'PK\x03\x04' + (b' ' * 26) + b'mimetype' + b'image/openraster' + res = self.magic.match_data(data) + self.check_mimetype(res, 'image', 'openraster') + def test_match_file(self): png_file = os.path.join(self.tmpdir, 'image') with open(png_file, 'wb') as f: |