From 1d5feb81e597db8faa53695315befbccf0075b2e Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Tue, 21 Mar 2023 16:45:56 +0000 Subject: [PATCH] ttFont_test: add reproducer for SpooledTemporaryFile has no seekable Reproduces https://github.com/fonttools/fonttools/issues/3052 --- Tests/ttLib/ttFont_test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Tests/ttLib/ttFont_test.py b/Tests/ttLib/ttFont_test.py index a2a61baf2..f726ad45c 100644 --- a/Tests/ttLib/ttFont_test.py +++ b/Tests/ttLib/ttFont_test.py @@ -2,6 +2,7 @@ import io import os import re import random +import tempfile from fontTools.feaLib.builder import addOpenTypeFeaturesFromString from fontTools.ttLib import ( TTFont, @@ -274,3 +275,14 @@ def test_getGlyphID(): font.getGlyphID("non_existent") with pytest.raises(KeyError): font.getGlyphID("glyph_prefix_but_invalid_id") + + +def test_spooled_tempfile_may_not_have_attribute_seekable(): + # SpooledTemporaryFile only got a seekable attribute on Python 3.11 + # https://github.com/fonttools/fonttools/issues/3052 + font = TTFont() + font.importXML(os.path.join(DATA_DIR, "TestTTF-Regular.ttx")) + tmp = tempfile.SpooledTemporaryFile() + font.save(tmp) + # this should not fail + _ = TTFont(tmp)