From e1b3bfc807800a240442be4c7b890c2d0280204b Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Thu, 17 Mar 2022 11:43:08 +0000 Subject: [PATCH] ttCollection_test: check loading TTCollection with lazy attribute currently lazy=True fails with 'ValueError: seek of closed file' --- Tests/ttLib/ttCollection_test.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Tests/ttLib/ttCollection_test.py diff --git a/Tests/ttLib/ttCollection_test.py b/Tests/ttLib/ttCollection_test.py new file mode 100644 index 000000000..e4c3b55a1 --- /dev/null +++ b/Tests/ttLib/ttCollection_test.py @@ -0,0 +1,14 @@ +import os +from fontTools.ttLib import TTCollection +import pytest + +TTX_DATA_DIR = os.path.join(os.path.dirname(__file__), "..", "ttx", "data") + + +@pytest.mark.parametrize("lazy", [None, True, False]) +def test_lazy_open(lazy): + ttc = os.path.join(TTX_DATA_DIR, "TestTTC.ttc") + with TTCollection(ttc, lazy=lazy) as collection: + assert len(collection) == 2 + assert collection[0]["maxp"].numGlyphs == 6 + assert collection[1]["maxp"].numGlyphs == 6