[varLib tests] Move test results to separate folder
This commit is contained in:
parent
bfccdbb5d5
commit
274654d440
@ -31,6 +31,11 @@ class InterpolateLayoutTest(unittest.TestCase):
|
||||
path, _ = os.path.split(__file__)
|
||||
return os.path.join(path, "data", test_file_or_folder)
|
||||
|
||||
@staticmethod
|
||||
def get_test_output(test_file_or_folder):
|
||||
path, _ = os.path.split(__file__)
|
||||
return os.path.join(path, "data", "test_results", test_file_or_folder)
|
||||
|
||||
@staticmethod
|
||||
def get_file_list(folder, suffix):
|
||||
all_files = os.listdir(folder)
|
||||
@ -108,7 +113,7 @@ class InterpolateLayoutTest(unittest.TestCase):
|
||||
instfont = interpolate_layout(ds_path, {'weight': 500}, finder)
|
||||
|
||||
tables = ['GSUB']
|
||||
expected_ttx_path = ds_path.replace('.designspace', '.ttx')
|
||||
expected_ttx_path = self.get_test_output('InterpolateLayout.ttx')
|
||||
self.expect_ttx(instfont, expected_ttx_path, tables)
|
||||
self.check_ttx_dump(instfont, expected_ttx_path, tables, suffix)
|
||||
|
||||
|
@ -32,6 +32,11 @@ class MutatorTest(unittest.TestCase):
|
||||
path, _ = os.path.split(__file__)
|
||||
return os.path.join(path, "data", test_file_or_folder)
|
||||
|
||||
@staticmethod
|
||||
def get_test_output(test_file_or_folder):
|
||||
path, _ = os.path.split(__file__)
|
||||
return os.path.join(path, "data", "test_results", test_file_or_folder)
|
||||
|
||||
@staticmethod
|
||||
def get_file_list(folder, suffix):
|
||||
all_files = os.listdir(folder)
|
||||
@ -96,7 +101,8 @@ class MutatorTest(unittest.TestCase):
|
||||
|
||||
finder = lambda s: s.replace(ufo_dir, self.tempdir).replace('.ufo', suffix)
|
||||
varfont, _, _ = build(ds_path, finder)
|
||||
varfont_path = os.path.join(self.tempdir, 'Mutator' + suffix)
|
||||
varfont_name = 'Mutator'
|
||||
varfont_path = os.path.join(self.tempdir, varfont_name + suffix)
|
||||
varfont.save(varfont_path)
|
||||
|
||||
args = [varfont_path, 'wght=500', 'cntr=50']
|
||||
@ -105,7 +111,7 @@ class MutatorTest(unittest.TestCase):
|
||||
instfont_path = os.path.splitext(varfont_path)[0] + '-instance' + suffix
|
||||
instfont = TTFont(instfont_path)
|
||||
tables = [table_tag for table_tag in instfont.keys() if table_tag != 'head']
|
||||
expected_ttx = self.get_test_input('Mutator.ttx')
|
||||
expected_ttx = self.get_test_output(varfont_name + '.ttx')
|
||||
self.expect_ttx(instfont, expected_ttx, tables)
|
||||
|
||||
|
||||
|
@ -31,6 +31,11 @@ class BuildTest(unittest.TestCase):
|
||||
path, _ = os.path.split(__file__)
|
||||
return os.path.join(path, "data", test_file_or_folder)
|
||||
|
||||
@staticmethod
|
||||
def get_test_output(test_file_or_folder):
|
||||
path, _ = os.path.split(__file__)
|
||||
return os.path.join(path, "data", "test_results", test_file_or_folder)
|
||||
|
||||
@staticmethod
|
||||
def get_file_list(folder, suffix):
|
||||
all_files = os.listdir(folder)
|
||||
@ -70,6 +75,12 @@ class BuildTest(unittest.TestCase):
|
||||
sys.stdout.write(line)
|
||||
self.fail("TTX output is different from expected")
|
||||
|
||||
def check_ttx_dump(self, font, expected_ttx, tables, suffix):
|
||||
"""Ensure the TTX dump is the same after saving and reloading the font."""
|
||||
path = self.temp_path(suffix=suffix)
|
||||
font.save(path)
|
||||
self.expect_ttx(TTFont(path), expected_ttx, tables)
|
||||
|
||||
def compile_font(self, path, suffix, temp_dir):
|
||||
ttx_filename = os.path.basename(path)
|
||||
savepath = os.path.join(temp_dir, ttx_filename.replace('.ttx', suffix))
|
||||
@ -97,13 +108,9 @@ class BuildTest(unittest.TestCase):
|
||||
varfont, model, _ = build(ds_path, finder)
|
||||
|
||||
tables = ['GDEF', 'HVAR', 'fvar', 'gvar']
|
||||
expected_ttx = self.get_test_input('Build.ttx')
|
||||
self.expect_ttx(varfont, expected_ttx, tables)
|
||||
|
||||
# ensure the TTX dump is the same after saving and reloading font
|
||||
varfont_path = os.path.join(self.tempdir, 'Build.ttf')
|
||||
varfont.save(varfont_path)
|
||||
self.expect_ttx(TTFont(varfont_path), expected_ttx, tables)
|
||||
expected_ttx_path = self.get_test_output('Build.ttx')
|
||||
self.expect_ttx(varfont, expected_ttx_path, tables)
|
||||
self.check_ttx_dump(varfont, expected_ttx_path, tables, suffix)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user