Debian Codegraph @

tests/test_fontsetter.py

raw symbols SCIP
1 from gftools.scripts.fontsetter import setter, getter
2 import pytest
3 from fontTools.ttLib import TTFont
4 import os
5
6
7 TEST_FONT = TTFont(os.path.join("data", "test", "Inconsolata[wdth,wght].ttf"))
8
9
10 @pytest.mark.parametrize(
11 """obj,path,val,res""",
12 [
13 ([10], [0], 100, [100]),
14 ([10, [10]], [1, 0], 100, [10, [100]]),
15 ([(0, [1, (2,)]), [1, 0], 100, (0, [100, (2,)])]),
16 ([[0, (0, (0,))], [1, 1, 0], 100, [0, (0, (100,))]]),
17 ({"A": {"B": [0, [10]]}}, ["A", "B", 1], [100], {"A": {"B": [0, [100]]}}),
18 ([0x1], [0], "|= 0x2", [0x3]),
19 ],
20 )
21 def test_setter(obj, path, val, res):
22 setter(obj, path, val)
23 assert obj == res
24
25
26 @pytest.mark.parametrize(
27 """obj,path,val""",
28 [
29 # simple atttribs
30 (TEST_FONT, ["OS/2", "fsSelection"], 64),
31 (TEST_FONT, ["hhea", "ascender"], 1000),
32 # attrib then dict
33 (TEST_FONT, ["hmtx", "metrics", "A"], (10, 10)),
34 # attrib then attrib
35 (TEST_FONT, ["OS/2", "panose", "bSerifStyle"], 10),
36 ],
37 )
38 def test_setter_on_fonts(obj, path, val):
39 setter(obj, path, val)
40 assert getter(obj, path) == val