fonttools/Tests/ttLib/tables/_k_e_r_n_test.py
Cosimo Lupo e1d340cc65
[Tests] use absolute imports and add __init__.py where relevant
We can't use relative imports any more since the tests are now located outside the package.

I had to add __init__.py to Tests/feaLib/ so that pytest does not get confused by the presence
of two test files with the same basename: i.e. Tests/feaLib/builder_test.py and Tests/feaLib/builder_test.py

https://github.com/pytest-dev/pytest/issues/774
http://stackoverflow.com/questions/12582503/py-test-test-discovery-failure-when-tests-in-different-directories-are-called
2017-01-16 09:14:13 +00:00

31 lines
1.2 KiB
Python

from __future__ import print_function, absolute_import
from fontTools.misc.py23 import *
from fontTools import ttLib
import unittest
from fontTools.ttLib.tables._k_e_r_n import KernTable_format_0
class MockFont(object):
def getGlyphOrder(self):
return ["glyph00000", "glyph00001", "glyph00002", "glyph00003"]
def getGlyphName(self, glyphID):
return "glyph%.5d" % glyphID
class KernTable_format_0_Test(unittest.TestCase):
def test_decompileBadGlyphId(self):
subtable = KernTable_format_0()
subtable.apple = False
subtable.decompile( b'\x00' * 6
+ b'\x00' + b'\x02' + b'\x00' * 6
+ b'\x00' + b'\x01' + b'\x00' + b'\x03' + b'\x00' + b'\x01'
+ b'\x00' + b'\x01' + b'\xFF' + b'\xFF' + b'\x00' + b'\x02',
MockFont())
self.assertEqual(subtable[("glyph00001", "glyph00003")], 1)
self.assertEqual(subtable[("glyph00001", "glyph65535")], 2)
if __name__ == "__main__":
import sys
sys.exit(unittest.main())