ttFont_test: add reproducer for SpooledTemporaryFile has no seekable

Reproduces https://github.com/fonttools/fonttools/issues/3052
This commit is contained in:
Cosimo Lupo 2023-03-21 16:45:56 +00:00
parent f1c609aa57
commit 1d5feb81e5
No known key found for this signature in database
GPG Key ID: DF65A8A5A119C9A8

View File

@ -2,6 +2,7 @@ import io
import os import os
import re import re
import random import random
import tempfile
from fontTools.feaLib.builder import addOpenTypeFeaturesFromString from fontTools.feaLib.builder import addOpenTypeFeaturesFromString
from fontTools.ttLib import ( from fontTools.ttLib import (
TTFont, TTFont,
@ -274,3 +275,14 @@ def test_getGlyphID():
font.getGlyphID("non_existent") font.getGlyphID("non_existent")
with pytest.raises(KeyError): with pytest.raises(KeyError):
font.getGlyphID("glyph_prefix_but_invalid_id") 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)