From e1d340cc654c45bdbec9c5633e99247f3931d7db Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Sun, 15 Jan 2017 21:45:57 +0000 Subject: [PATCH] [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 --- Tests/feaLib/__init__.py | 0 Tests/misc/encodingTools_test.py | 2 +- Tests/misc/macRes_test.py | 2 +- Tests/misc/xmlReader_test.py | 2 +- Tests/misc/xmlWriter_test.py | 2 +- Tests/ttLib/tables/O_S_2f_2_test.py | 2 +- Tests/ttLib/tables/_c_m_a_p_test.py | 2 +- Tests/ttLib/tables/_k_e_r_n_test.py | 2 +- Tests/ttLib/tables/_l_t_a_g_test.py | 2 +- Tests/ttLib/tables/_n_a_m_e_test.py | 4 ++-- Tests/ttLib/tables/_v_m_t_x_test.py | 2 +- Tests/ttLib/woff2_test.py | 3 ++- 12 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 Tests/feaLib/__init__.py diff --git a/Tests/feaLib/__init__.py b/Tests/feaLib/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/Tests/misc/encodingTools_test.py b/Tests/misc/encodingTools_test.py index 2efaeb0ce..4c9628b7b 100644 --- a/Tests/misc/encodingTools_test.py +++ b/Tests/misc/encodingTools_test.py @@ -1,7 +1,7 @@ from __future__ import print_function, division, absolute_import, unicode_literals from fontTools.misc.py23 import * import unittest -from .encodingTools import getEncoding +from fontTools.misc.encodingTools import getEncoding class EncodingTest(unittest.TestCase): diff --git a/Tests/misc/macRes_test.py b/Tests/misc/macRes_test.py index feaa33e57..fde13f87f 100644 --- a/Tests/misc/macRes_test.py +++ b/Tests/misc/macRes_test.py @@ -5,7 +5,7 @@ import os import tempfile import unittest from fontTools.misc.textTools import deHexStr -from .macRes import ResourceReader +from fontTools.misc.macRes import ResourceReader # test resource data in DeRez notation diff --git a/Tests/misc/xmlReader_test.py b/Tests/misc/xmlReader_test.py index a2c9aa2c8..622abf5cd 100644 --- a/Tests/misc/xmlReader_test.py +++ b/Tests/misc/xmlReader_test.py @@ -5,7 +5,7 @@ from fontTools.misc.py23 import * import os import unittest from fontTools.ttLib import TTFont -from .xmlReader import XMLReader, ProgressPrinter, BUFSIZE +from fontTools.misc.xmlReader import XMLReader, ProgressPrinter, BUFSIZE import tempfile diff --git a/Tests/misc/xmlWriter_test.py b/Tests/misc/xmlWriter_test.py index 3ee63c63c..0930e1cec 100644 --- a/Tests/misc/xmlWriter_test.py +++ b/Tests/misc/xmlWriter_test.py @@ -2,7 +2,7 @@ from __future__ import print_function, division, absolute_import from fontTools.misc.py23 import * import os import unittest -from .xmlWriter import XMLWriter +from fontTools.misc.xmlWriter import XMLWriter linesep = tobytes(os.linesep) HEADER = b'' + linesep diff --git a/Tests/ttLib/tables/O_S_2f_2_test.py b/Tests/ttLib/tables/O_S_2f_2_test.py index 1dc18a108..819190eee 100644 --- a/Tests/ttLib/tables/O_S_2f_2_test.py +++ b/Tests/ttLib/tables/O_S_2f_2_test.py @@ -1,6 +1,6 @@ from __future__ import print_function, division, absolute_import from fontTools.ttLib import TTFont, newTable, getTableModule -from .O_S_2f_2 import * +from fontTools.ttLib.tables.O_S_2f_2 import * import unittest diff --git a/Tests/ttLib/tables/_c_m_a_p_test.py b/Tests/ttLib/tables/_c_m_a_p_test.py index 1fadcde7a..73ac2395c 100644 --- a/Tests/ttLib/tables/_c_m_a_p_test.py +++ b/Tests/ttLib/tables/_c_m_a_p_test.py @@ -2,7 +2,7 @@ from __future__ import print_function, division, absolute_import, unicode_litera from fontTools.misc.py23 import * from fontTools import ttLib import unittest -from ._c_m_a_p import CmapSubtable, table__c_m_a_p +from fontTools.ttLib.tables._c_m_a_p import CmapSubtable, table__c_m_a_p class CmapSubtableTest(unittest.TestCase): diff --git a/Tests/ttLib/tables/_k_e_r_n_test.py b/Tests/ttLib/tables/_k_e_r_n_test.py index 932047439..1dacb936e 100644 --- a/Tests/ttLib/tables/_k_e_r_n_test.py +++ b/Tests/ttLib/tables/_k_e_r_n_test.py @@ -2,7 +2,7 @@ from __future__ import print_function, absolute_import from fontTools.misc.py23 import * from fontTools import ttLib import unittest -from ._k_e_r_n import KernTable_format_0 +from fontTools.ttLib.tables._k_e_r_n import KernTable_format_0 class MockFont(object): diff --git a/Tests/ttLib/tables/_l_t_a_g_test.py b/Tests/ttLib/tables/_l_t_a_g_test.py index a24c3460a..78a05edb2 100644 --- a/Tests/ttLib/tables/_l_t_a_g_test.py +++ b/Tests/ttLib/tables/_l_t_a_g_test.py @@ -5,7 +5,7 @@ from fontTools.misc.xmlWriter import XMLWriter import os import struct import unittest -from ._l_t_a_g import table__l_t_a_g +from fontTools.ttLib.tables._l_t_a_g import table__l_t_a_g class Test_l_t_a_g(unittest.TestCase): diff --git a/Tests/ttLib/tables/_n_a_m_e_test.py b/Tests/ttLib/tables/_n_a_m_e_test.py index 9656fa524..30f1044f8 100644 --- a/Tests/ttLib/tables/_n_a_m_e_test.py +++ b/Tests/ttLib/tables/_n_a_m_e_test.py @@ -6,8 +6,8 @@ from fontTools.misc.xmlWriter import XMLWriter from fontTools.misc.loggingTools import CapturingLogHandler import struct import unittest -from ._n_a_m_e import table__n_a_m_e, NameRecord, nameRecordFormat, nameRecordSize -from ._n_a_m_e import makeName, log +from fontTools.ttLib.tables._n_a_m_e import ( + table__n_a_m_e, NameRecord, nameRecordFormat, nameRecordSize, makeName, log) class NameTableTest(unittest.TestCase): diff --git a/Tests/ttLib/tables/_v_m_t_x_test.py b/Tests/ttLib/tables/_v_m_t_x_test.py index 4c9f08c7a..f55dbeca9 100644 --- a/Tests/ttLib/tables/_v_m_t_x_test.py +++ b/Tests/ttLib/tables/_v_m_t_x_test.py @@ -2,7 +2,7 @@ from __future__ import print_function, division, absolute_import from __future__ import unicode_literals from fontTools.misc.py23 import * from fontTools.ttLib.tables._v_m_t_x import table__v_m_t_x -from fontTools.ttLib.tables import _h_m_t_x_test +import _h_m_t_x_test import unittest diff --git a/Tests/ttLib/woff2_test.py b/Tests/ttLib/woff2_test.py index 4ecc970c9..d12b876d7 100644 --- a/Tests/ttLib/woff2_test.py +++ b/Tests/ttLib/woff2_test.py @@ -1,7 +1,8 @@ from __future__ import print_function, division, absolute_import, unicode_literals from fontTools.misc.py23 import * from fontTools import ttLib -from .woff2 import (WOFF2Reader, woff2DirectorySize, woff2DirectoryFormat, +from fontTools.ttLib.woff2 import ( + WOFF2Reader, woff2DirectorySize, woff2DirectoryFormat, woff2FlagsSize, woff2UnknownTagSize, woff2Base128MaxSize, WOFF2DirectoryEntry, getKnownTagIndex, packBase128, base128Size, woff2UnknownTagIndex, WOFF2FlavorData, woff2TransformedTableTags, WOFF2GlyfTable, WOFF2LocaTable,