summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorjvoisin2019-09-01 09:28:46 -0700
committerjvoisin2019-09-01 09:28:46 -0700
commit397a18b0cc6453c9d72ce2cd110f3724ac809313 (patch)
treee87174f3cbeeb4be071bf5deb2fc55a62f757ec1 /tests
parentfc924239febb3f186585d9ea6c263e1cb7dc690d (diff)
Add support for ppm
Diffstat (limited to '')
-rw-r--r--tests/data/dirty.ppm8
-rw-r--r--tests/test_libmat2.py29
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/data/dirty.ppm b/tests/data/dirty.ppm
new file mode 100644
index 0000000..d658cd3
--- /dev/null
+++ b/tests/data/dirty.ppm
@@ -0,0 +1,8 @@
1P3
2# A metadata
33 2 1
41 0 1 0 1 0 0 0 1
5# And an other one
61 1 0 1 0 1 1 0 0
7 # and a final one here
8
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py
index 3fba36a..d596ff2 100644
--- a/tests/test_libmat2.py
+++ b/tests/test_libmat2.py
@@ -113,6 +113,14 @@ class TestGetMeta(unittest.TestCase):
113 meta = p.get_meta() 113 meta = p.get_meta()
114 self.assertEqual(meta['Comment'], 'Created with GIMP') 114 self.assertEqual(meta['Comment'], 'Created with GIMP')
115 115
116 def test_ppm(self):
117 p = images.PPMParser('./tests/data/dirty.ppm')
118 meta = p.get_meta()
119 self.assertEqual(meta['1'], '# A metadata')
120 self.assertEqual(meta['4'], '# And an other one')
121 self.assertEqual(meta['6'], '# and a final one here')
122
123
116 def test_tiff(self): 124 def test_tiff(self):
117 p = images.TiffParser('./tests/data/dirty.tiff') 125 p = images.TiffParser('./tests/data/dirty.tiff')
118 meta = p.get_meta() 126 meta = p.get_meta()
@@ -887,3 +895,24 @@ class TestCleaning(unittest.TestCase):
887 895
888 p = images.SVGParser('./tests/data/weird.svg') 896 p = images.SVGParser('./tests/data/weird.svg')
889 self.assertEqual(p.get_meta()['Xmlns'], 'http://www.w3.org/1337/svg') 897 self.assertEqual(p.get_meta()['Xmlns'], 'http://www.w3.org/1337/svg')
898
899 def test_ppm(self):
900 shutil.copy('./tests/data/dirty.ppm', './tests/data/clean.ppm')
901 p = images.PPMParser('./tests/data/clean.ppm')
902
903 meta = p.get_meta()
904 print(meta)
905 self.assertEqual(meta['1'], '# A metadata')
906
907 ret = p.remove_all()
908 self.assertTrue(ret)
909
910 p = images.PPMParser('./tests/data/clean.cleaned.ppm')
911 self.assertEqual(p.get_meta(), {})
912 self.assertTrue(p.remove_all())
913
914 os.remove('./tests/data/clean.ppm')
915 os.remove('./tests/data/clean.cleaned.ppm')
916 os.remove('./tests/data/clean.cleaned.cleaned.ppm')
917
918