diff options
author | jaseg <git@jaseg.de> | 2023-03-29 22:42:49 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-03-29 22:42:49 +0200 |
commit | 10669301a14caff853df0b97495a03872e4f507f (patch) | |
tree | 89c1975aa09da4e517db49b0e722be156f8b9a13 | |
parent | 25628f1d24a6902e7f7d18befeb751b0a7305fd5 (diff) | |
download | gerbolyze-10669301a14caff853df0b97495a03872e4f507f.tar.gz gerbolyze-10669301a14caff853df0b97495a03872e4f507f.tar.bz2 gerbolyze-10669301a14caff853df0b97495a03872e4f507f.zip |
svg-flatten: Add stroke mapping test
-rw-r--r-- | svg-flatten/src/test/svg_tests.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/svg-flatten/src/test/svg_tests.py b/svg-flatten/src/test/svg_tests.py index d91bc0d..6afefda 100644 --- a/svg-flatten/src/test/svg_tests.py +++ b/svg-flatten/src/test/svg_tests.py @@ -36,12 +36,12 @@ def run_svg_flatten(input_file, output_file, *args, **kwargs): args.append(str(output_file)) try: - proc = subprocess.run(args, capture_output=True, check=True) - except: + proc = subprocess.run(args, capture_output=True, check=True, text=True) + except subprocess.CalledProcessError as e: print('Subprocess stdout:') - print(proc.stdout.decode()) + print(e.stdout) print('Subprocess stderr:') - print(proc.stderr.decode()) + print(e.stderr) raise def run_cargo_cmd(cmd, args, **kwargs): @@ -213,6 +213,19 @@ class SVGRoundTripTests(unittest.TestCase): e.args = (msg, *rest) raise e +class StrokeMappingTests(unittest.TestCase): + def test_stroke_mapping(self): + test_in_svg = 'testdata/svg/xform_uniformity_threshold.svg' + + with tempfile.NamedTemporaryFile(suffix='.svg') as tmp_out_svg: + + run_svg_flatten(test_in_svg, tmp_out_svg.name, format='svg') + + with open(tmp_out_svg.name, 'r') as f: + num_strokes = sum(1 for l in f.readlines() if 'stroke=' in l) + self.assertEqual(num_strokes, 84) + + for test_in_svg in Path('testdata/svg').glob('*.svg'): # We need to make sure we capture the loop variable's current value here. gen = lambda testcase: lambda self: self.run_svg_round_trip_test(testcase) |