From b77f5edadf7b243c1d29e5012d34fda24910fa6d Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Fri, 18 Nov 2022 12:12:40 +0000 Subject: [PATCH] maximum_color_test: reproduce #435 input file contains spaces --- tests/maximum_color_test.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/maximum_color_test.py b/tests/maximum_color_test.py index c2a4d509..1c829b51 100644 --- a/tests/maximum_color_test.py +++ b/tests/maximum_color_test.py @@ -63,6 +63,14 @@ def _maximize_color(initial_font_file: Path, additional_flags: Tuple[str, ...]) return maxmium_font_file +@pytest.mark.parametrize( + "input_file", + [ + "Font.ttf", + # test that we don't crash when filename contains spaces + "Color Font.ttf", + ], +) @pytest.mark.parametrize( "color_format, expected_new_tables", [ @@ -71,18 +79,21 @@ def _maximize_color(initial_font_file: Path, additional_flags: Tuple[str, ...]) ], ) @pytest.mark.parametrize("bitmaps", [True, False]) -def test_build_maximum_font(color_format, expected_new_tables, bitmaps): +def test_build_maximum_font(color_format, expected_new_tables, bitmaps, input_file): initial_font_file = _build_initial_font(color_format) + input_file = initial_font_file.parent / input_file + initial_font_file.rename(input_file) + bitmap_flag = "--nobitmaps" if bitmaps: bitmap_flag = "--bitmaps" expected_new_tables = copy.copy(expected_new_tables) expected_new_tables.update({"CBDT", "CBLC"}) - maxmium_font_file = _maximize_color(initial_font_file, (bitmap_flag,)) + maxmium_font_file = _maximize_color(input_file, (bitmap_flag,)) - initial_font = ttLib.TTFont(initial_font_file) + initial_font = ttLib.TTFont(input_file) maximum_font = ttLib.TTFont(maxmium_font_file) assert set(maximum_font.keys()) - set(initial_font.keys()) == expected_new_tables