parametrize ttCompile timestamp tests

This commit is contained in:
Chris Simpkins 2018-05-22 07:50:23 -04:00
parent c2fe5d25fd
commit f2eb328125

View File

@ -742,11 +742,14 @@ def test_ttcompile_ttf_to_woff2(tmpdir):
assert table in ttf assert table in ttf
# TODO: convert to pytest parametrize for this and the next test @pytest.mark.parametrize("inpath, outpath1, outpath2",
def test_ttcompile_ttf_timestamp_calcs(tmpdir): [("TestTTF.ttx", "TestTTF1.ttf", "TestTTF2.ttf"),
inttx = os.path.join("Tests", "ttx", "data", "TestTTF.ttx") ("TestOTF.ttx", "TestOTF1.otf", "TestOTF2.otf")
outttf1 = os.path.join(str(tmpdir), "TestTTF1.ttf") ])
outttf2 = os.path.join(str(tmpdir), "TestTTF2.ttf") def test_ttcompile_timestamp_calcs(inpath, outpath1, outpath2, tmpdir):
inttx = os.path.join("Tests", "ttx", "data", inpath)
outttf1 = os.path.join(str(tmpdir), outpath1)
outttf2 = os.path.join(str(tmpdir), outpath2)
options = ttx.Options([], 1) options = ttx.Options([], 1)
# build with default options = do not recalculate timestamp # build with default options = do not recalculate timestamp
ttx.ttCompile(inttx, outttf1, options) ttx.ttCompile(inttx, outttf1, options)
@ -770,33 +773,6 @@ def test_ttcompile_ttf_timestamp_calcs(tmpdir):
assert ttf["head"].modified > epochtime assert ttf["head"].modified > epochtime
def test_ttcompile_otf_timestamp_calcs(tmpdir):
inttx = os.path.join("Tests", "ttx", "data", "TestOTF.ttx")
outotf1 = os.path.join(str(tmpdir), "TestOTF1.ttf")
outotf2 = os.path.join(str(tmpdir), "TestOTF2.ttf")
options = ttx.Options([], 1)
# build with default options = do not recalculate timestamp
ttx.ttCompile(inttx, outotf1, options)
# confirm that font was built
assert os.path.isfile(outotf1)
# confirm that timestamp is same as modified time on ttx file
mtime = os.path.getmtime(inttx)
epochtime = timestampSinceEpoch(mtime)
ttf = TTFont(outotf1)
assert ttf["head"].modified == epochtime
# reset options to recalculate the timestamp and compile new font
options.recalcTimestamp = True
ttx.ttCompile(inttx, outotf2, options)
# confirm that font was built
assert os.path.isfile(outotf2) is True
# confirm that timestamp is more recent than modified time on ttx file
mtime = os.path.getmtime(inttx)
epochtime = timestampSinceEpoch(mtime)
ttf = TTFont(outotf2)
assert ttf["head"].modified > epochtime
# ------------------------- # -------------------------
# ttx.ttList function tests # ttx.ttList function tests
# ------------------------- # -------------------------