diff --git a/Tests/subset/subset_test.py b/Tests/subset/subset_test.py index a9595cf4b..ae9be7e2d 100644 --- a/Tests/subset/subset_test.py +++ b/Tests/subset/subset_test.py @@ -800,14 +800,16 @@ class SubsetTest: ) @pytest.mark.parametrize( - "installed, ok", + "installed, enabled, ok", [ - pytest.param(True, True, id="installed-ok"), - pytest.param(True, False, id="installed-fail"), - pytest.param(False, True, id="not_installed"), + pytest.param(True, True, True, id="installed-enabled-ok"), + pytest.param(True, True, False, id="installed-enabled-fail"), + pytest.param(True, False, True, id="installed-disabled"), + pytest.param(False, True, True, id="not_installed-enabled"), + pytest.param(False, False, True, id="not_installed-disabled"), ], ) - def test_harfbuzz_repacker(self, caplog, monkeypatch, installed, ok): + def test_harfbuzz_repacker(self, caplog, monkeypatch, installed, enabled, ok): # Use a mock to test the pure-python serializer is used when uharfbuzz # returns an error or is not installed have_uharfbuzz = fontTools.ttLib.tables.otBase.have_uharfbuzz @@ -831,26 +833,41 @@ class SubsetTest: fontpath = self.compile_font(self.getpath("harfbuzz_repacker.ttx"), ".otf") subsetpath = self.temp_path(".otf") - with caplog.at_level(logging.ERROR, "fontTools.ttLib.tables.otBase"): - subset.main( - [ - fontpath, - "--unicodes=0x53a9", - "--layout-features=*", - f"--output-file={subsetpath}", - ] - ) + args = [ + fontpath, + "--unicodes=0x53a9", + "--layout-features=*", + f"--output-file={subsetpath}", + ] + if not enabled: + args.append("--no-harfbuzz-repacker") + + with caplog.at_level(logging.DEBUG, "fontTools.ttLib.tables.otBase"): + subset.main(args) + subsetfont = TTFont(subsetpath) # both hb.repack and pure-python serializer compile to the same ttx self.expect_ttx( subsetfont, self.getpath("expect_harfbuzz_repacker.ttx"), ["GSUB"] ) + if enabled: + if installed: + assert "serializing 'GSUB' with hb.repack" in caplog.text + else: + assert ( + "uharfbuzz not found, compiling 'GSUB' with pure-python serializer" + ) in caplog.text + else: + assert ( + "hb.repack disabled, compiling 'GSUB' with pure-python serializer" + ) in caplog.text + # test we emit a log.error if hb.repack fails (and we don't if successful) assert ( ( - "hb.repack failed, reverting to pure-python serializer; " - "the error message was: mocking" + "hb.repack failed to serialize 'GSUB', reverting to " + "pure-python serializer; the error message was: mocking" ) in caplog.text ) ^ ok