1
0
mirror of synced 2024-11-22 01:04:23 +01:00

Fix the svg tests on archlinux

This commit is contained in:
jvoisin 2022-03-28 22:43:22 +02:00
parent 5ccddae7f5
commit 2a74a400e2

View File

@ -445,7 +445,10 @@ class TestCleaning(unittest.TestCase):
'meta': { 'meta': {
'WorkDescription': "This is a test svg image for mat2's testsuite", 'WorkDescription': "This is a test svg image for mat2's testsuite",
}, },
'expected_meta': {}, 'expected_meta': {
'ImageSize': '128x128',
'Megapixels': '0.016',
},
} ,{ } ,{
'name': 'ppm', 'name': 'ppm',
'parser': images.PPMParser, 'parser': images.PPMParser,
@ -506,41 +509,42 @@ class TestCleaning(unittest.TestCase):
def test_all_parametred(self): def test_all_parametred(self):
for case in self.data: for case in self.data:
if 'ffmpeg' in case: with self.subTest(case=case):
try: if 'ffmpeg' in case:
video._get_ffmpeg_path() try:
except RuntimeError: video._get_ffmpeg_path()
raise unittest.SkipTest except RuntimeError:
raise unittest.SkipTest
print('[+] Testing %s' % case['name']) print('[+] Testing %s' % case['name'])
target = './tests/data/clean.' + case['name'] target = './tests/data/clean.' + case['name']
shutil.copy('./tests/data/dirty.' + case['name'], target) shutil.copy('./tests/data/dirty.' + case['name'], target)
p1 = case['parser'](target) p1 = case['parser'](target)
for k, v in p1.get_meta().items(): for k, v in p1.get_meta().items():
if k not in case['meta']: if k not in case['meta']:
continue continue
if isinstance(v, dict): if isinstance(v, dict):
for _k, _v in v.items(): for _k, _v in v.items():
if _k in case['meta'][k]: if _k in case['meta'][k]:
self.assertEqual(_v, case['meta'][k][_k]) self.assertEqual(_v, case['meta'][k][_k])
else: else:
self.assertEqual(v, case['meta'][k]) self.assertEqual(v, case['meta'][k])
p1.lightweight_cleaning = True p1.lightweight_cleaning = True
self.assertTrue(p1.remove_all()) self.assertTrue(p1.remove_all())
p2 = case['parser'](p1.output_filename) p2 = case['parser'](p1.output_filename)
meta = p2.get_meta() meta = p2.get_meta()
if meta: if meta:
for k, v in p2.get_meta().items(): for k, v in p2.get_meta().items():
self.assertIn(k, case['expected_meta'], '"%s" is not in "%s" (%s)' % (k, case['expected_meta'], case['name'])) self.assertIn(k, case['expected_meta'], '"%s" is not in "%s" (%s)' % (k, case['expected_meta'], case['name']))
self.assertIn(str(case['expected_meta'][k]), str(v)) self.assertIn(str(case['expected_meta'][k]), str(v))
self.assertTrue(p2.remove_all()) self.assertTrue(p2.remove_all())
os.remove(target) os.remove(target)
os.remove(p1.output_filename) os.remove(p1.output_filename)
os.remove(p2.output_filename) os.remove(p2.output_filename)
def test_html(self): def test_html(self):