diff options
| author | jvoisin | 2022-03-28 22:43:22 +0200 |
|---|---|---|
| committer | jvoisin | 2022-03-28 23:22:42 +0200 |
| commit | 2a74a400e20cbefa820d840dfef478ec73aa2843 (patch) | |
| tree | f4b111e5e59c8c16a7c10e0b49120728c2f357da | |
| parent | 5ccddae7f5a4482d0868158f19ceddf8a20c9225 (diff) | |
Fix the svg tests on archlinux
| -rw-r--r-- | tests/test_libmat2.py | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index 0a39377..9e56969 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py | |||
| @@ -445,7 +445,10 @@ class TestCleaning(unittest.TestCase): | |||
| 445 | 'meta': { | 445 | 'meta': { |
| 446 | 'WorkDescription': "This is a test svg image for mat2's testsuite", | 446 | 'WorkDescription': "This is a test svg image for mat2's testsuite", |
| 447 | }, | 447 | }, |
| 448 | 'expected_meta': {}, | 448 | 'expected_meta': { |
| 449 | 'ImageSize': '128x128', | ||
| 450 | 'Megapixels': '0.016', | ||
| 451 | }, | ||
| 449 | } ,{ | 452 | } ,{ |
| 450 | 'name': 'ppm', | 453 | 'name': 'ppm', |
| 451 | 'parser': images.PPMParser, | 454 | 'parser': images.PPMParser, |
| @@ -506,41 +509,42 @@ class TestCleaning(unittest.TestCase): | |||
| 506 | 509 | ||
| 507 | def test_all_parametred(self): | 510 | def test_all_parametred(self): |
| 508 | for case in self.data: | 511 | for case in self.data: |
| 509 | if 'ffmpeg' in case: | 512 | with self.subTest(case=case): |
| 510 | try: | 513 | if 'ffmpeg' in case: |
| 511 | video._get_ffmpeg_path() | 514 | try: |
| 512 | except RuntimeError: | 515 | video._get_ffmpeg_path() |
| 513 | raise unittest.SkipTest | 516 | except RuntimeError: |
| 517 | raise unittest.SkipTest | ||
| 514 | 518 | ||
| 515 | print('[+] Testing %s' % case['name']) | 519 | print('[+] Testing %s' % case['name']) |
| 516 | target = './tests/data/clean.' + case['name'] | 520 | target = './tests/data/clean.' + case['name'] |
| 517 | shutil.copy('./tests/data/dirty.' + case['name'], target) | 521 | shutil.copy('./tests/data/dirty.' + case['name'], target) |
| 518 | p1 = case['parser'](target) | 522 | p1 = case['parser'](target) |
| 519 | 523 | ||
| 520 | for k, v in p1.get_meta().items(): | 524 | for k, v in p1.get_meta().items(): |
| 521 | if k not in case['meta']: | 525 | if k not in case['meta']: |
| 522 | continue | 526 | continue |
| 523 | if isinstance(v, dict): | 527 | if isinstance(v, dict): |
| 524 | for _k, _v in v.items(): | 528 | for _k, _v in v.items(): |
| 525 | if _k in case['meta'][k]: | 529 | if _k in case['meta'][k]: |
| 526 | self.assertEqual(_v, case['meta'][k][_k]) | 530 | self.assertEqual(_v, case['meta'][k][_k]) |
| 527 | else: | 531 | else: |
| 528 | self.assertEqual(v, case['meta'][k]) | 532 | self.assertEqual(v, case['meta'][k]) |
| 529 | 533 | ||
| 530 | p1.lightweight_cleaning = True | 534 | p1.lightweight_cleaning = True |
| 531 | self.assertTrue(p1.remove_all()) | 535 | self.assertTrue(p1.remove_all()) |
| 532 | 536 | ||
| 533 | p2 = case['parser'](p1.output_filename) | 537 | p2 = case['parser'](p1.output_filename) |
| 534 | meta = p2.get_meta() | 538 | meta = p2.get_meta() |
| 535 | if meta: | 539 | if meta: |
| 536 | for k, v in p2.get_meta().items(): | 540 | for k, v in p2.get_meta().items(): |
| 537 | self.assertIn(k, case['expected_meta'], '"%s" is not in "%s" (%s)' % (k, case['expected_meta'], case['name'])) | 541 | self.assertIn(k, case['expected_meta'], '"%s" is not in "%s" (%s)' % (k, case['expected_meta'], case['name'])) |
| 538 | self.assertIn(str(case['expected_meta'][k]), str(v)) | 542 | self.assertIn(str(case['expected_meta'][k]), str(v)) |
| 539 | self.assertTrue(p2.remove_all()) | 543 | self.assertTrue(p2.remove_all()) |
| 540 | 544 | ||
| 541 | os.remove(target) | 545 | os.remove(target) |
| 542 | os.remove(p1.output_filename) | 546 | os.remove(p1.output_filename) |
| 543 | os.remove(p2.output_filename) | 547 | os.remove(p2.output_filename) |
| 544 | 548 | ||
| 545 | 549 | ||
| 546 | def test_html(self): | 550 | def test_html(self): |
