woff2_test: fix up flaky tests

some tests were failing when shuffling the order of the tests with
pytest-randomly. That's because calling TTFont.getTableData method
on 'loca' table before having compiled 'glyf' returns an empty b""
string.
This commit is contained in:
Cosimo Lupo 2019-06-11 12:44:46 +01:00
parent 6ea99e4569
commit 9af92fdb41
No known key found for this signature in database
GPG Key ID: 20D4A261E4A0E642

View File

@ -145,6 +145,7 @@ class WOFF2ReaderTTFTest(WOFF2ReaderTest):
def test_reconstruct_loca(self):
woff2Reader = WOFF2Reader(self.file)
reconstructedData = woff2Reader['loca']
self.font.getTableData("glyf") # 'glyf' needs to be compiled before 'loca'
self.assertEqual(self.font.getTableData('loca'), reconstructedData)
self.assertTrue(hasattr(woff2Reader.tables['glyf'], 'data'))
@ -360,7 +361,7 @@ class WOFF2WriterTest(unittest.TestCase):
def setUpClass(cls):
cls.font = ttLib.TTFont(recalcBBoxes=False, recalcTimestamp=False, flavor="woff2")
cls.font.importXML(OTX)
cls.tags = [t for t in cls.font.keys() if t != 'GlyphOrder']
cls.tags = sorted(t for t in cls.font.keys() if t != 'GlyphOrder')
cls.numTables = len(cls.tags)
cls.file = BytesIO(CFF_WOFF2.getvalue())
cls.file.seek(0, 2)
@ -518,7 +519,7 @@ class WOFF2WriterTTFTest(WOFF2WriterTest):
def setUpClass(cls):
cls.font = ttLib.TTFont(recalcBBoxes=False, recalcTimestamp=False, flavor="woff2")
cls.font.importXML(TTX)
cls.tags = [t for t in cls.font.keys() if t != 'GlyphOrder']
cls.tags = sorted(t for t in cls.font.keys() if t != 'GlyphOrder')
cls.numTables = len(cls.tags)
cls.file = BytesIO(TT_WOFF2.getvalue())
cls.file.seek(0, 2)