diff --git a/Lib/fontTools/misc/arrayTools.py b/Lib/fontTools/misc/arrayTools.py index 93651ae55..a3b495b23 100644 --- a/Lib/fontTools/misc/arrayTools.py +++ b/Lib/fontTools/misc/arrayTools.py @@ -23,7 +23,7 @@ def calcIntBounds(array): tuple: (xMin, yMin, xMax, yMax) Values are rounded to closest integer. """ - return tuple(int(round(v)) for v in calcBounds(array)) + return tuple(round(v) for v in calcBounds(array)) def updateBounds(bounds, p, min=min, max=max): diff --git a/MANIFEST.in b/MANIFEST.in index 705143a85..88234ff5c 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -12,10 +12,11 @@ include run-tests.sh recursive-include Doc/man/man1 *.1 -recursive-include Lib/fontTools testdata/*.ttx testdata/*.otx testdata/*.fea -recursive-include Lib/fontTools testdata/*.feax -recursive-include Lib/fontTools testdata/*.txt testdata/*.ttx.* -recursive-include Lib/fontTools testdata/mti/*.txt testdata/mti/*.ttx.* -recursive-include Lib/fontTools testdata/mti/*.ttx testdata/mti/README -recursive-include Lib/fontTools testdata/*.lwfn testdata/*.pfa testdata/*.pfb -recursive-include Lib/fontTools testdata/*.xml testdata/*.designspace testdata/*.bin +recursive-include Tests *.py +recursive-include Tests data/*.ttx data/*.otx data/*.fea +recursive-include Tests data/*.feax +recursive-include Tests data/*.txt data/*.ttx.* +recursive-include Tests data/mti/*.txt data/mti/*.ttx.* +recursive-include Tests data/mti/*.ttx data/mti/README +recursive-include Tests data/*.lwfn data/*.pfa data/*.pfb +recursive-include Tests data/*.xml data/*.designspace data/*.bin diff --git a/README.md b/README.md index a29379ffa..a971c7809 100644 --- a/README.md +++ b/README.md @@ -130,15 +130,25 @@ To run the test suite, you can do: python setup.py test ``` -Or if you have [pytest](http://docs.pytest.org/en/latest/), you can run the `pytest` command directly. +If you have [pytest](http://docs.pytest.org/en/latest/), you can run the `pytest` command directly. +The tests will run against the installed `fontTools` package, or the first one found in the `PYTHONPATH`. -We also use [tox](https://testrun.org/tox/latest/) to automatically test on different Python versions in isolated virtual environments. +You can also use [tox](https://testrun.org/tox/latest/) to automatically run tests on different Python versions in isolated virtual environments. ```sh -pip install -r dev-requirements.txt +pip install tox tox ``` +Note that when you run `tox` without arguments, the tests are executed for all the environments listed in tox.ini's `envlist`. In our case, this includes Python 2.7, 3.5 and 3.6, so for this to work the `python2.7`, `python3.5` and `python3.6` executables must be available in your `PATH`. + +You can specify an alternative environment list via the `-e` option, or the `TOXENV` environment variable: + +```sh +tox -e py27-nocov +TOXENV="py{27,36}-cov" tox +``` + ### Development Community TTX/FontTools development is ongoing in an active community of developers, that includes professional developers employed at major software corporations and type foundries as well as hobbyists. diff --git a/Lib/fontTools/agl_test.py b/Tests/agl_test.py similarity index 100% rename from Lib/fontTools/agl_test.py rename to Tests/agl_test.py diff --git a/Lib/fontTools/encodings/codecs_test.py b/Tests/encodings/codecs_test.py similarity index 100% rename from Lib/fontTools/encodings/codecs_test.py rename to Tests/encodings/codecs_test.py diff --git a/Tests/feaLib/__init__.py b/Tests/feaLib/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/Lib/fontTools/feaLib/builder_test.py b/Tests/feaLib/builder_test.py similarity index 99% rename from Lib/fontTools/feaLib/builder_test.py rename to Tests/feaLib/builder_test.py index 7cd972099..8f3e3eea7 100644 --- a/Lib/fontTools/feaLib/builder_test.py +++ b/Tests/feaLib/builder_test.py @@ -49,7 +49,7 @@ def makeTTFont(): class BuilderTest(unittest.TestCase): - # Feature files in testdata/*.fea; output gets compared to testdata/*.ttx. + # Feature files in data/*.fea; output gets compared to data/*.ttx. TEST_FEATURE_FILES = """ Attach enum markClass language_required GlyphClassDef LigatureCaretByIndex LigatureCaretByPos @@ -86,7 +86,7 @@ class BuilderTest(unittest.TestCase): @staticmethod def getpath(testfile): path, _ = os.path.split(__file__) - return os.path.join(path, "testdata", testfile) + return os.path.join(path, "data", testfile) def temp_path(self, suffix): if not self.tempdir: diff --git a/Lib/fontTools/feaLib/testdata/Attach.fea b/Tests/feaLib/data/Attach.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/Attach.fea rename to Tests/feaLib/data/Attach.fea diff --git a/Lib/fontTools/feaLib/testdata/Attach.ttx b/Tests/feaLib/data/Attach.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/Attach.ttx rename to Tests/feaLib/data/Attach.ttx diff --git a/Lib/fontTools/feaLib/testdata/GPOS_1.fea b/Tests/feaLib/data/GPOS_1.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_1.fea rename to Tests/feaLib/data/GPOS_1.fea diff --git a/Lib/fontTools/feaLib/testdata/GPOS_1.ttx b/Tests/feaLib/data/GPOS_1.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_1.ttx rename to Tests/feaLib/data/GPOS_1.ttx diff --git a/Lib/fontTools/feaLib/testdata/GPOS_1_zero.fea b/Tests/feaLib/data/GPOS_1_zero.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_1_zero.fea rename to Tests/feaLib/data/GPOS_1_zero.fea diff --git a/Lib/fontTools/feaLib/testdata/GPOS_1_zero.ttx b/Tests/feaLib/data/GPOS_1_zero.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_1_zero.ttx rename to Tests/feaLib/data/GPOS_1_zero.ttx diff --git a/Lib/fontTools/feaLib/testdata/GPOS_2.fea b/Tests/feaLib/data/GPOS_2.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_2.fea rename to Tests/feaLib/data/GPOS_2.fea diff --git a/Lib/fontTools/feaLib/testdata/GPOS_2.ttx b/Tests/feaLib/data/GPOS_2.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_2.ttx rename to Tests/feaLib/data/GPOS_2.ttx diff --git a/Lib/fontTools/feaLib/testdata/GPOS_2b.fea b/Tests/feaLib/data/GPOS_2b.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_2b.fea rename to Tests/feaLib/data/GPOS_2b.fea diff --git a/Lib/fontTools/feaLib/testdata/GPOS_2b.ttx b/Tests/feaLib/data/GPOS_2b.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_2b.ttx rename to Tests/feaLib/data/GPOS_2b.ttx diff --git a/Lib/fontTools/feaLib/testdata/GPOS_3.fea b/Tests/feaLib/data/GPOS_3.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_3.fea rename to Tests/feaLib/data/GPOS_3.fea diff --git a/Lib/fontTools/feaLib/testdata/GPOS_3.ttx b/Tests/feaLib/data/GPOS_3.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_3.ttx rename to Tests/feaLib/data/GPOS_3.ttx diff --git a/Lib/fontTools/feaLib/testdata/GPOS_4.fea b/Tests/feaLib/data/GPOS_4.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_4.fea rename to Tests/feaLib/data/GPOS_4.fea diff --git a/Lib/fontTools/feaLib/testdata/GPOS_4.ttx b/Tests/feaLib/data/GPOS_4.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_4.ttx rename to Tests/feaLib/data/GPOS_4.ttx diff --git a/Lib/fontTools/feaLib/testdata/GPOS_5.fea b/Tests/feaLib/data/GPOS_5.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_5.fea rename to Tests/feaLib/data/GPOS_5.fea diff --git a/Lib/fontTools/feaLib/testdata/GPOS_5.ttx b/Tests/feaLib/data/GPOS_5.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_5.ttx rename to Tests/feaLib/data/GPOS_5.ttx diff --git a/Lib/fontTools/feaLib/testdata/GPOS_6.fea b/Tests/feaLib/data/GPOS_6.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_6.fea rename to Tests/feaLib/data/GPOS_6.fea diff --git a/Lib/fontTools/feaLib/testdata/GPOS_6.ttx b/Tests/feaLib/data/GPOS_6.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_6.ttx rename to Tests/feaLib/data/GPOS_6.ttx diff --git a/Lib/fontTools/feaLib/testdata/GPOS_8.fea b/Tests/feaLib/data/GPOS_8.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_8.fea rename to Tests/feaLib/data/GPOS_8.fea diff --git a/Lib/fontTools/feaLib/testdata/GPOS_8.ttx b/Tests/feaLib/data/GPOS_8.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/GPOS_8.ttx rename to Tests/feaLib/data/GPOS_8.ttx diff --git a/Lib/fontTools/feaLib/testdata/GSUB_2.fea b/Tests/feaLib/data/GSUB_2.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/GSUB_2.fea rename to Tests/feaLib/data/GSUB_2.fea diff --git a/Lib/fontTools/feaLib/testdata/GSUB_2.ttx b/Tests/feaLib/data/GSUB_2.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/GSUB_2.ttx rename to Tests/feaLib/data/GSUB_2.ttx diff --git a/Lib/fontTools/feaLib/testdata/GSUB_3.fea b/Tests/feaLib/data/GSUB_3.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/GSUB_3.fea rename to Tests/feaLib/data/GSUB_3.fea diff --git a/Lib/fontTools/feaLib/testdata/GSUB_3.ttx b/Tests/feaLib/data/GSUB_3.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/GSUB_3.ttx rename to Tests/feaLib/data/GSUB_3.ttx diff --git a/Lib/fontTools/feaLib/testdata/GSUB_6.fea b/Tests/feaLib/data/GSUB_6.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/GSUB_6.fea rename to Tests/feaLib/data/GSUB_6.fea diff --git a/Lib/fontTools/feaLib/testdata/GSUB_6.ttx b/Tests/feaLib/data/GSUB_6.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/GSUB_6.ttx rename to Tests/feaLib/data/GSUB_6.ttx diff --git a/Lib/fontTools/feaLib/testdata/GSUB_8.fea b/Tests/feaLib/data/GSUB_8.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/GSUB_8.fea rename to Tests/feaLib/data/GSUB_8.fea diff --git a/Lib/fontTools/feaLib/testdata/GSUB_8.ttx b/Tests/feaLib/data/GSUB_8.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/GSUB_8.ttx rename to Tests/feaLib/data/GSUB_8.ttx diff --git a/Lib/fontTools/feaLib/testdata/GlyphClassDef.fea b/Tests/feaLib/data/GlyphClassDef.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/GlyphClassDef.fea rename to Tests/feaLib/data/GlyphClassDef.fea diff --git a/Lib/fontTools/feaLib/testdata/GlyphClassDef.ttx b/Tests/feaLib/data/GlyphClassDef.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/GlyphClassDef.ttx rename to Tests/feaLib/data/GlyphClassDef.ttx diff --git a/Lib/fontTools/feaLib/testdata/LigatureCaretByIndex.fea b/Tests/feaLib/data/LigatureCaretByIndex.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/LigatureCaretByIndex.fea rename to Tests/feaLib/data/LigatureCaretByIndex.fea diff --git a/Lib/fontTools/feaLib/testdata/LigatureCaretByIndex.ttx b/Tests/feaLib/data/LigatureCaretByIndex.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/LigatureCaretByIndex.ttx rename to Tests/feaLib/data/LigatureCaretByIndex.ttx diff --git a/Lib/fontTools/feaLib/testdata/LigatureCaretByPos.fea b/Tests/feaLib/data/LigatureCaretByPos.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/LigatureCaretByPos.fea rename to Tests/feaLib/data/LigatureCaretByPos.fea diff --git a/Lib/fontTools/feaLib/testdata/LigatureCaretByPos.ttx b/Tests/feaLib/data/LigatureCaretByPos.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/LigatureCaretByPos.ttx rename to Tests/feaLib/data/LigatureCaretByPos.ttx diff --git a/Lib/fontTools/feaLib/testdata/baseClass.fea b/Tests/feaLib/data/baseClass.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/baseClass.fea rename to Tests/feaLib/data/baseClass.fea diff --git a/Lib/fontTools/feaLib/testdata/baseClass.feax b/Tests/feaLib/data/baseClass.feax similarity index 100% rename from Lib/fontTools/feaLib/testdata/baseClass.feax rename to Tests/feaLib/data/baseClass.feax diff --git a/Lib/fontTools/feaLib/testdata/bug453.fea b/Tests/feaLib/data/bug453.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug453.fea rename to Tests/feaLib/data/bug453.fea diff --git a/Lib/fontTools/feaLib/testdata/bug453.ttx b/Tests/feaLib/data/bug453.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug453.ttx rename to Tests/feaLib/data/bug453.ttx diff --git a/Lib/fontTools/feaLib/testdata/bug457.fea b/Tests/feaLib/data/bug457.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug457.fea rename to Tests/feaLib/data/bug457.fea diff --git a/Lib/fontTools/feaLib/testdata/bug457.ttx b/Tests/feaLib/data/bug457.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug457.ttx rename to Tests/feaLib/data/bug457.ttx diff --git a/Lib/fontTools/feaLib/testdata/bug463.fea b/Tests/feaLib/data/bug463.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug463.fea rename to Tests/feaLib/data/bug463.fea diff --git a/Lib/fontTools/feaLib/testdata/bug463.ttx b/Tests/feaLib/data/bug463.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug463.ttx rename to Tests/feaLib/data/bug463.ttx diff --git a/Lib/fontTools/feaLib/testdata/bug501.fea b/Tests/feaLib/data/bug501.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug501.fea rename to Tests/feaLib/data/bug501.fea diff --git a/Lib/fontTools/feaLib/testdata/bug501.ttx b/Tests/feaLib/data/bug501.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug501.ttx rename to Tests/feaLib/data/bug501.ttx diff --git a/Lib/fontTools/feaLib/testdata/bug502.fea b/Tests/feaLib/data/bug502.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug502.fea rename to Tests/feaLib/data/bug502.fea diff --git a/Lib/fontTools/feaLib/testdata/bug502.ttx b/Tests/feaLib/data/bug502.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug502.ttx rename to Tests/feaLib/data/bug502.ttx diff --git a/Lib/fontTools/feaLib/testdata/bug504.fea b/Tests/feaLib/data/bug504.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug504.fea rename to Tests/feaLib/data/bug504.fea diff --git a/Lib/fontTools/feaLib/testdata/bug504.ttx b/Tests/feaLib/data/bug504.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug504.ttx rename to Tests/feaLib/data/bug504.ttx diff --git a/Lib/fontTools/feaLib/testdata/bug505.fea b/Tests/feaLib/data/bug505.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug505.fea rename to Tests/feaLib/data/bug505.fea diff --git a/Lib/fontTools/feaLib/testdata/bug505.ttx b/Tests/feaLib/data/bug505.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug505.ttx rename to Tests/feaLib/data/bug505.ttx diff --git a/Lib/fontTools/feaLib/testdata/bug506.fea b/Tests/feaLib/data/bug506.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug506.fea rename to Tests/feaLib/data/bug506.fea diff --git a/Lib/fontTools/feaLib/testdata/bug506.ttx b/Tests/feaLib/data/bug506.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug506.ttx rename to Tests/feaLib/data/bug506.ttx diff --git a/Lib/fontTools/feaLib/testdata/bug509.fea b/Tests/feaLib/data/bug509.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug509.fea rename to Tests/feaLib/data/bug509.fea diff --git a/Lib/fontTools/feaLib/testdata/bug509.ttx b/Tests/feaLib/data/bug509.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug509.ttx rename to Tests/feaLib/data/bug509.ttx diff --git a/Lib/fontTools/feaLib/testdata/bug512.fea b/Tests/feaLib/data/bug512.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug512.fea rename to Tests/feaLib/data/bug512.fea diff --git a/Lib/fontTools/feaLib/testdata/bug512.ttx b/Tests/feaLib/data/bug512.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug512.ttx rename to Tests/feaLib/data/bug512.ttx diff --git a/Lib/fontTools/feaLib/testdata/bug568.fea b/Tests/feaLib/data/bug568.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug568.fea rename to Tests/feaLib/data/bug568.fea diff --git a/Lib/fontTools/feaLib/testdata/bug568.ttx b/Tests/feaLib/data/bug568.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/bug568.ttx rename to Tests/feaLib/data/bug568.ttx diff --git a/Lib/fontTools/feaLib/testdata/enum.fea b/Tests/feaLib/data/enum.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/enum.fea rename to Tests/feaLib/data/enum.fea diff --git a/Lib/fontTools/feaLib/testdata/enum.ttx b/Tests/feaLib/data/enum.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/enum.ttx rename to Tests/feaLib/data/enum.ttx diff --git a/Lib/fontTools/feaLib/testdata/feature_aalt.fea b/Tests/feaLib/data/feature_aalt.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/feature_aalt.fea rename to Tests/feaLib/data/feature_aalt.fea diff --git a/Lib/fontTools/feaLib/testdata/feature_aalt.ttx b/Tests/feaLib/data/feature_aalt.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/feature_aalt.ttx rename to Tests/feaLib/data/feature_aalt.ttx diff --git a/Lib/fontTools/feaLib/testdata/ignore_pos.fea b/Tests/feaLib/data/ignore_pos.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/ignore_pos.fea rename to Tests/feaLib/data/ignore_pos.fea diff --git a/Lib/fontTools/feaLib/testdata/ignore_pos.ttx b/Tests/feaLib/data/ignore_pos.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/ignore_pos.ttx rename to Tests/feaLib/data/ignore_pos.ttx diff --git a/Lib/fontTools/feaLib/testdata/include0.fea b/Tests/feaLib/data/include0.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/include0.fea rename to Tests/feaLib/data/include0.fea diff --git a/Lib/fontTools/feaLib/testdata/include1.fea b/Tests/feaLib/data/include1.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/include1.fea rename to Tests/feaLib/data/include1.fea diff --git a/Lib/fontTools/feaLib/testdata/include2.fea b/Tests/feaLib/data/include2.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/include2.fea rename to Tests/feaLib/data/include2.fea diff --git a/Lib/fontTools/feaLib/testdata/include3.fea b/Tests/feaLib/data/include3.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/include3.fea rename to Tests/feaLib/data/include3.fea diff --git a/Lib/fontTools/feaLib/testdata/include4.fea b/Tests/feaLib/data/include4.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/include4.fea rename to Tests/feaLib/data/include4.fea diff --git a/Lib/fontTools/feaLib/testdata/include5.fea b/Tests/feaLib/data/include5.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/include5.fea rename to Tests/feaLib/data/include5.fea diff --git a/Lib/fontTools/feaLib/testdata/include6.fea b/Tests/feaLib/data/include6.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/include6.fea rename to Tests/feaLib/data/include6.fea diff --git a/Lib/fontTools/feaLib/testdata/includemissingfile.fea b/Tests/feaLib/data/includemissingfile.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/includemissingfile.fea rename to Tests/feaLib/data/includemissingfile.fea diff --git a/Lib/fontTools/feaLib/testdata/includeself.fea b/Tests/feaLib/data/includeself.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/includeself.fea rename to Tests/feaLib/data/includeself.fea diff --git a/Lib/fontTools/feaLib/testdata/language_required.fea b/Tests/feaLib/data/language_required.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/language_required.fea rename to Tests/feaLib/data/language_required.fea diff --git a/Lib/fontTools/feaLib/testdata/language_required.ttx b/Tests/feaLib/data/language_required.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/language_required.ttx rename to Tests/feaLib/data/language_required.ttx diff --git a/Lib/fontTools/feaLib/testdata/lookup.fea b/Tests/feaLib/data/lookup.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/lookup.fea rename to Tests/feaLib/data/lookup.fea diff --git a/Lib/fontTools/feaLib/testdata/lookup.ttx b/Tests/feaLib/data/lookup.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/lookup.ttx rename to Tests/feaLib/data/lookup.ttx diff --git a/Lib/fontTools/feaLib/testdata/lookupflag.fea b/Tests/feaLib/data/lookupflag.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/lookupflag.fea rename to Tests/feaLib/data/lookupflag.fea diff --git a/Lib/fontTools/feaLib/testdata/lookupflag.ttx b/Tests/feaLib/data/lookupflag.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/lookupflag.ttx rename to Tests/feaLib/data/lookupflag.ttx diff --git a/Lib/fontTools/feaLib/testdata/markClass.fea b/Tests/feaLib/data/markClass.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/markClass.fea rename to Tests/feaLib/data/markClass.fea diff --git a/Lib/fontTools/feaLib/testdata/markClass.ttx b/Tests/feaLib/data/markClass.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/markClass.ttx rename to Tests/feaLib/data/markClass.ttx diff --git a/Lib/fontTools/feaLib/testdata/mini.fea b/Tests/feaLib/data/mini.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/mini.fea rename to Tests/feaLib/data/mini.fea diff --git a/Lib/fontTools/feaLib/testdata/multiple_feature_blocks.fea b/Tests/feaLib/data/multiple_feature_blocks.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/multiple_feature_blocks.fea rename to Tests/feaLib/data/multiple_feature_blocks.fea diff --git a/Lib/fontTools/feaLib/testdata/multiple_feature_blocks.ttx b/Tests/feaLib/data/multiple_feature_blocks.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/multiple_feature_blocks.ttx rename to Tests/feaLib/data/multiple_feature_blocks.ttx diff --git a/Lib/fontTools/feaLib/testdata/name.fea b/Tests/feaLib/data/name.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/name.fea rename to Tests/feaLib/data/name.fea diff --git a/Lib/fontTools/feaLib/testdata/name.ttx b/Tests/feaLib/data/name.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/name.ttx rename to Tests/feaLib/data/name.ttx diff --git a/Lib/fontTools/feaLib/testdata/omitted_GlyphClassDef.fea b/Tests/feaLib/data/omitted_GlyphClassDef.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/omitted_GlyphClassDef.fea rename to Tests/feaLib/data/omitted_GlyphClassDef.fea diff --git a/Lib/fontTools/feaLib/testdata/omitted_GlyphClassDef.ttx b/Tests/feaLib/data/omitted_GlyphClassDef.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/omitted_GlyphClassDef.ttx rename to Tests/feaLib/data/omitted_GlyphClassDef.ttx diff --git a/Lib/fontTools/feaLib/testdata/size.fea b/Tests/feaLib/data/size.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/size.fea rename to Tests/feaLib/data/size.fea diff --git a/Lib/fontTools/feaLib/testdata/size.ttx b/Tests/feaLib/data/size.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/size.ttx rename to Tests/feaLib/data/size.ttx diff --git a/Lib/fontTools/feaLib/testdata/size2.fea b/Tests/feaLib/data/size2.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/size2.fea rename to Tests/feaLib/data/size2.fea diff --git a/Lib/fontTools/feaLib/testdata/size2.ttx b/Tests/feaLib/data/size2.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/size2.ttx rename to Tests/feaLib/data/size2.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec10.fea b/Tests/feaLib/data/spec10.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec10.fea rename to Tests/feaLib/data/spec10.fea diff --git a/Lib/fontTools/feaLib/testdata/spec10.ttx b/Tests/feaLib/data/spec10.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec10.ttx rename to Tests/feaLib/data/spec10.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec4h1.fea b/Tests/feaLib/data/spec4h1.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec4h1.fea rename to Tests/feaLib/data/spec4h1.fea diff --git a/Lib/fontTools/feaLib/testdata/spec4h1.ttx b/Tests/feaLib/data/spec4h1.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec4h1.ttx rename to Tests/feaLib/data/spec4h1.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec4h2.fea b/Tests/feaLib/data/spec4h2.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec4h2.fea rename to Tests/feaLib/data/spec4h2.fea diff --git a/Lib/fontTools/feaLib/testdata/spec4h2.ttx b/Tests/feaLib/data/spec4h2.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec4h2.ttx rename to Tests/feaLib/data/spec4h2.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec5d1.fea b/Tests/feaLib/data/spec5d1.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5d1.fea rename to Tests/feaLib/data/spec5d1.fea diff --git a/Lib/fontTools/feaLib/testdata/spec5d1.ttx b/Tests/feaLib/data/spec5d1.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5d1.ttx rename to Tests/feaLib/data/spec5d1.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec5d2.fea b/Tests/feaLib/data/spec5d2.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5d2.fea rename to Tests/feaLib/data/spec5d2.fea diff --git a/Lib/fontTools/feaLib/testdata/spec5d2.ttx b/Tests/feaLib/data/spec5d2.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5d2.ttx rename to Tests/feaLib/data/spec5d2.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec5f_ii_1.fea b/Tests/feaLib/data/spec5f_ii_1.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5f_ii_1.fea rename to Tests/feaLib/data/spec5f_ii_1.fea diff --git a/Lib/fontTools/feaLib/testdata/spec5f_ii_1.ttx b/Tests/feaLib/data/spec5f_ii_1.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5f_ii_1.ttx rename to Tests/feaLib/data/spec5f_ii_1.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec5f_ii_2.fea b/Tests/feaLib/data/spec5f_ii_2.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5f_ii_2.fea rename to Tests/feaLib/data/spec5f_ii_2.fea diff --git a/Lib/fontTools/feaLib/testdata/spec5f_ii_2.ttx b/Tests/feaLib/data/spec5f_ii_2.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5f_ii_2.ttx rename to Tests/feaLib/data/spec5f_ii_2.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec5f_ii_3.fea b/Tests/feaLib/data/spec5f_ii_3.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5f_ii_3.fea rename to Tests/feaLib/data/spec5f_ii_3.fea diff --git a/Lib/fontTools/feaLib/testdata/spec5f_ii_3.ttx b/Tests/feaLib/data/spec5f_ii_3.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5f_ii_3.ttx rename to Tests/feaLib/data/spec5f_ii_3.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec5f_ii_4.fea b/Tests/feaLib/data/spec5f_ii_4.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5f_ii_4.fea rename to Tests/feaLib/data/spec5f_ii_4.fea diff --git a/Lib/fontTools/feaLib/testdata/spec5f_ii_4.ttx b/Tests/feaLib/data/spec5f_ii_4.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5f_ii_4.ttx rename to Tests/feaLib/data/spec5f_ii_4.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec5fi1.fea b/Tests/feaLib/data/spec5fi1.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5fi1.fea rename to Tests/feaLib/data/spec5fi1.fea diff --git a/Lib/fontTools/feaLib/testdata/spec5fi1.ttx b/Tests/feaLib/data/spec5fi1.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5fi1.ttx rename to Tests/feaLib/data/spec5fi1.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec5fi2.fea b/Tests/feaLib/data/spec5fi2.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5fi2.fea rename to Tests/feaLib/data/spec5fi2.fea diff --git a/Lib/fontTools/feaLib/testdata/spec5fi2.ttx b/Tests/feaLib/data/spec5fi2.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5fi2.ttx rename to Tests/feaLib/data/spec5fi2.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec5fi3.fea b/Tests/feaLib/data/spec5fi3.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5fi3.fea rename to Tests/feaLib/data/spec5fi3.fea diff --git a/Lib/fontTools/feaLib/testdata/spec5fi3.ttx b/Tests/feaLib/data/spec5fi3.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5fi3.ttx rename to Tests/feaLib/data/spec5fi3.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec5fi4.fea b/Tests/feaLib/data/spec5fi4.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5fi4.fea rename to Tests/feaLib/data/spec5fi4.fea diff --git a/Lib/fontTools/feaLib/testdata/spec5fi4.ttx b/Tests/feaLib/data/spec5fi4.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5fi4.ttx rename to Tests/feaLib/data/spec5fi4.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec5h1.fea b/Tests/feaLib/data/spec5h1.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5h1.fea rename to Tests/feaLib/data/spec5h1.fea diff --git a/Lib/fontTools/feaLib/testdata/spec5h1.ttx b/Tests/feaLib/data/spec5h1.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec5h1.ttx rename to Tests/feaLib/data/spec5h1.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec6b_ii.fea b/Tests/feaLib/data/spec6b_ii.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec6b_ii.fea rename to Tests/feaLib/data/spec6b_ii.fea diff --git a/Lib/fontTools/feaLib/testdata/spec6b_ii.ttx b/Tests/feaLib/data/spec6b_ii.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec6b_ii.ttx rename to Tests/feaLib/data/spec6b_ii.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec6d2.fea b/Tests/feaLib/data/spec6d2.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec6d2.fea rename to Tests/feaLib/data/spec6d2.fea diff --git a/Lib/fontTools/feaLib/testdata/spec6d2.ttx b/Tests/feaLib/data/spec6d2.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec6d2.ttx rename to Tests/feaLib/data/spec6d2.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec6e.fea b/Tests/feaLib/data/spec6e.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec6e.fea rename to Tests/feaLib/data/spec6e.fea diff --git a/Lib/fontTools/feaLib/testdata/spec6e.ttx b/Tests/feaLib/data/spec6e.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec6e.ttx rename to Tests/feaLib/data/spec6e.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec6f.fea b/Tests/feaLib/data/spec6f.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec6f.fea rename to Tests/feaLib/data/spec6f.fea diff --git a/Lib/fontTools/feaLib/testdata/spec6f.ttx b/Tests/feaLib/data/spec6f.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec6f.ttx rename to Tests/feaLib/data/spec6f.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec6h_ii.fea b/Tests/feaLib/data/spec6h_ii.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec6h_ii.fea rename to Tests/feaLib/data/spec6h_ii.fea diff --git a/Lib/fontTools/feaLib/testdata/spec6h_ii.ttx b/Tests/feaLib/data/spec6h_ii.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec6h_ii.ttx rename to Tests/feaLib/data/spec6h_ii.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec6h_iii_1.fea b/Tests/feaLib/data/spec6h_iii_1.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec6h_iii_1.fea rename to Tests/feaLib/data/spec6h_iii_1.fea diff --git a/Lib/fontTools/feaLib/testdata/spec6h_iii_1.ttx b/Tests/feaLib/data/spec6h_iii_1.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec6h_iii_1.ttx rename to Tests/feaLib/data/spec6h_iii_1.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec6h_iii_3d.fea b/Tests/feaLib/data/spec6h_iii_3d.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec6h_iii_3d.fea rename to Tests/feaLib/data/spec6h_iii_3d.fea diff --git a/Lib/fontTools/feaLib/testdata/spec6h_iii_3d.ttx b/Tests/feaLib/data/spec6h_iii_3d.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec6h_iii_3d.ttx rename to Tests/feaLib/data/spec6h_iii_3d.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec8a.fea b/Tests/feaLib/data/spec8a.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec8a.fea rename to Tests/feaLib/data/spec8a.fea diff --git a/Lib/fontTools/feaLib/testdata/spec8a.ttx b/Tests/feaLib/data/spec8a.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec8a.ttx rename to Tests/feaLib/data/spec8a.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec8b.fea b/Tests/feaLib/data/spec8b.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec8b.fea rename to Tests/feaLib/data/spec8b.fea diff --git a/Lib/fontTools/feaLib/testdata/spec8b.ttx b/Tests/feaLib/data/spec8b.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec8b.ttx rename to Tests/feaLib/data/spec8b.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec8c.fea b/Tests/feaLib/data/spec8c.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec8c.fea rename to Tests/feaLib/data/spec8c.fea diff --git a/Lib/fontTools/feaLib/testdata/spec8c.ttx b/Tests/feaLib/data/spec8c.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec8c.ttx rename to Tests/feaLib/data/spec8c.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec9a.fea b/Tests/feaLib/data/spec9a.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9a.fea rename to Tests/feaLib/data/spec9a.fea diff --git a/Lib/fontTools/feaLib/testdata/spec9a.ttx b/Tests/feaLib/data/spec9a.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9a.ttx rename to Tests/feaLib/data/spec9a.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec9b.fea b/Tests/feaLib/data/spec9b.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9b.fea rename to Tests/feaLib/data/spec9b.fea diff --git a/Lib/fontTools/feaLib/testdata/spec9b.ttx b/Tests/feaLib/data/spec9b.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9b.ttx rename to Tests/feaLib/data/spec9b.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec9c1.fea b/Tests/feaLib/data/spec9c1.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9c1.fea rename to Tests/feaLib/data/spec9c1.fea diff --git a/Lib/fontTools/feaLib/testdata/spec9c1.ttx b/Tests/feaLib/data/spec9c1.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9c1.ttx rename to Tests/feaLib/data/spec9c1.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec9c2.fea b/Tests/feaLib/data/spec9c2.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9c2.fea rename to Tests/feaLib/data/spec9c2.fea diff --git a/Lib/fontTools/feaLib/testdata/spec9c2.ttx b/Tests/feaLib/data/spec9c2.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9c2.ttx rename to Tests/feaLib/data/spec9c2.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec9c3.fea b/Tests/feaLib/data/spec9c3.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9c3.fea rename to Tests/feaLib/data/spec9c3.fea diff --git a/Lib/fontTools/feaLib/testdata/spec9c3.ttx b/Tests/feaLib/data/spec9c3.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9c3.ttx rename to Tests/feaLib/data/spec9c3.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec9d.fea b/Tests/feaLib/data/spec9d.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9d.fea rename to Tests/feaLib/data/spec9d.fea diff --git a/Lib/fontTools/feaLib/testdata/spec9d.ttx b/Tests/feaLib/data/spec9d.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9d.ttx rename to Tests/feaLib/data/spec9d.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec9e.fea b/Tests/feaLib/data/spec9e.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9e.fea rename to Tests/feaLib/data/spec9e.fea diff --git a/Lib/fontTools/feaLib/testdata/spec9e.ttx b/Tests/feaLib/data/spec9e.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9e.ttx rename to Tests/feaLib/data/spec9e.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec9f.fea b/Tests/feaLib/data/spec9f.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9f.fea rename to Tests/feaLib/data/spec9f.fea diff --git a/Lib/fontTools/feaLib/testdata/spec9f.ttx b/Tests/feaLib/data/spec9f.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9f.ttx rename to Tests/feaLib/data/spec9f.ttx diff --git a/Lib/fontTools/feaLib/testdata/spec9g.fea b/Tests/feaLib/data/spec9g.fea similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9g.fea rename to Tests/feaLib/data/spec9g.fea diff --git a/Lib/fontTools/feaLib/testdata/spec9g.ttx b/Tests/feaLib/data/spec9g.ttx similarity index 100% rename from Lib/fontTools/feaLib/testdata/spec9g.ttx rename to Tests/feaLib/data/spec9g.ttx diff --git a/Lib/fontTools/feaLib/error_test.py b/Tests/feaLib/error_test.py similarity index 100% rename from Lib/fontTools/feaLib/error_test.py rename to Tests/feaLib/error_test.py diff --git a/Lib/fontTools/feaLib/lexer_test.py b/Tests/feaLib/lexer_test.py similarity index 99% rename from Lib/fontTools/feaLib/lexer_test.py rename to Tests/feaLib/lexer_test.py index 31e3c1015..7e4c249f9 100644 --- a/Lib/fontTools/feaLib/lexer_test.py +++ b/Tests/feaLib/lexer_test.py @@ -130,7 +130,7 @@ class IncludingLexerTest(unittest.TestCase): @staticmethod def getpath(filename): path, _ = os.path.split(__file__) - return os.path.join(path, "testdata", filename) + return os.path.join(path, "data", filename) def test_include(self): lexer = IncludingLexer(self.getpath("include4.fea")) diff --git a/Lib/fontTools/feaLib/parser_test.py b/Tests/feaLib/parser_test.py similarity index 99% rename from Lib/fontTools/feaLib/parser_test.py rename to Tests/feaLib/parser_test.py index ebfd52452..4fa22371a 100644 --- a/Lib/fontTools/feaLib/parser_test.py +++ b/Tests/feaLib/parser_test.py @@ -1281,7 +1281,7 @@ class ParserTest(unittest.TestCase): @staticmethod def getpath(testfile): path, _ = os.path.split(__file__) - return os.path.join(path, "testdata", testfile) + return os.path.join(path, "data", testfile) class SymbolTableTest(unittest.TestCase): diff --git a/Lib/fontTools/merge_test.py b/Tests/merge_test.py similarity index 100% rename from Lib/fontTools/merge_test.py rename to Tests/merge_test.py diff --git a/Tests/misc/arrayTools_test.py b/Tests/misc/arrayTools_test.py new file mode 100644 index 000000000..108b50da2 --- /dev/null +++ b/Tests/misc/arrayTools_test.py @@ -0,0 +1,85 @@ +from __future__ import print_function, division, absolute_import +from fontTools.misc.py23 import * +from fontTools.misc.arrayTools import ( + calcBounds, calcIntBounds, updateBounds, pointInRect, pointsInRect, + vectorLength, asInt16, normRect, scaleRect, offsetRect, insetRect, + sectRect, unionRect, rectCenter, intRect) +import math + + +def test_calcBounds(): + assert calcBounds([]) == (0, 0, 0, 0) + assert calcBounds( + [(0, 40), (0, 100), (50, 50), (80, 10)]) == (0, 10, 80, 100) + + +def test_calcIntBounds(): + assert calcIntBounds( + [(0.1, 40.1), (0.1, 100.1), (49.9, 49.9), (79.5, 9.5)] + ) == (0, 10, 80, 100) + + +def test_updateBounds(): + assert updateBounds((0, 0, 0, 0), (100, 100)) == (0, 0, 100, 100) + + +def test_pointInRect(): + assert pointInRect((50, 50), (0, 0, 100, 100)) + assert pointInRect((0, 0), (0, 0, 100, 100)) + assert pointInRect((100, 100), (0, 0, 100, 100)) + assert not pointInRect((101, 100), (0, 0, 100, 100)) + + +def test_pointsInRect(): + assert pointsInRect([], (0, 0, 100, 100)) == [] + assert pointsInRect( + [(50, 50), (0, 0), (100, 100), (101, 100)], + (0, 0, 100, 100)) == [True, True, True, False] + + +def test_vectorLength(): + assert vectorLength((1, 1)) == math.sqrt(2) + + +def test_asInt16(): + assert asInt16([0, 0.1, 0.5, 0.9]) == [0, 0, 1, 1] + + +def test_normRect(): + assert normRect((0, 10, 100, 200)) == (0, 10, 100, 200) + assert normRect((100, 200, 0, 10)) == (0, 10, 100, 200) + + +def test_scaleRect(): + assert scaleRect((10, 20, 50, 150), 1.5, 2) == (15.0, 40, 75.0, 300) + + +def test_offsetRect(): + assert offsetRect((10, 20, 30, 40), 5, 6) == (15, 26, 35, 46) + + +def test_insetRect(): + assert insetRect((10, 20, 50, 60), 5, 10) == (15, 30, 45, 50) + assert insetRect((10, 20, 50, 60), -5, -10) == (5, 10, 55, 70) + + +def test_sectRect(): + intersects, rect = sectRect((0, 10, 20, 30), (0, 40, 20, 50)) + assert not intersects + + intersects, rect = sectRect((0, 10, 20, 30), (5, 20, 35, 50)) + assert intersects + assert rect == (5, 20, 20, 30) + + +def test_unionRect(): + assert unionRect((0, 10, 20, 30), (0, 40, 20, 50)) == (0, 10, 20, 50) + + +def test_rectCenter(): + assert rectCenter((0, 0, 100, 200)) == (50.0, 100.0) + assert rectCenter((0, 0, 100, 199.0)) == (50.0, 99.5) + + +def test_intRect(): + assert intRect((0.9, 2.9, 3.1, 4.1)) == (0, 2, 4, 5) diff --git a/Tests/misc/bezierTools_test.py b/Tests/misc/bezierTools_test.py new file mode 100644 index 000000000..1519543f2 --- /dev/null +++ b/Tests/misc/bezierTools_test.py @@ -0,0 +1,133 @@ +from __future__ import print_function, division, absolute_import +from fontTools.misc.py23 import * +from fontTools.misc.bezierTools import ( + calcQuadraticBounds, calcCubicBounds, splitLine, splitQuadratic, + splitCubic, splitQuadraticAtT, splitCubicAtT, solveCubic) +import pytest + + +def test_calcQuadraticBounds(): + assert calcQuadraticBounds( + (0, 0), (50, 100), (100, 0)) == (0, 0, 100, 50.0) + assert calcQuadraticBounds( + (0, 0), (100, 0), (100, 100)) == (0.0, 0.0, 100, 100) + + +def test_calcCubicBounds(): + assert calcCubicBounds( + (0, 0), (25, 100), (75, 100), (100, 0)) == ((0, 0, 100, 75.0)) + assert calcCubicBounds( + (0, 0), (50, 0), (100, 50), (100, 100)) == (0.0, 0.0, 100, 100) + assert calcCubicBounds( + (50, 0), (0, 100), (100, 100), (50, 0) + ) == pytest.approx((35.566243, 0.000000, 64.433757, 75.000000)) + + +def test_splitLine(): + assert splitLine( + (0, 0), (100, 100), where=50, isHorizontal=True + ) == [((0, 0), (50.0, 50.0)), ((50.0, 50.0), (100, 100))] + assert splitLine( + (0, 0), (100, 100), where=100, isHorizontal=True + ) == [((0, 0), (100, 100))] + assert splitLine( + (0, 0), (100, 100), where=0, isHorizontal=True + ) == [((0, 0), (0, 0)), ((0, 0), (100, 100))] + assert splitLine( + (0, 0), (100, 100), where=0, isHorizontal=False + ) == [((0, 0), (0, 0)), ((0, 0), (100, 100))] + assert splitLine( + (100, 0), (0, 0), where=50, isHorizontal=False + ) == [((100, 0), (50, 0)), ((50, 0), (0, 0))] + assert splitLine( + (0, 100), (0, 0), where=50, isHorizontal=True + ) == [((0, 100), (0, 50)), ((0, 50), (0, 0))] + assert splitLine( + (0, 100), (100, 100), where=50, isHorizontal=True + ) == [((0, 100), (100, 100))] + + +def assert_curves_approx_equal(actual_curves, expected_curves): + assert len(actual_curves) == len(expected_curves) + for acurve, ecurve in zip(actual_curves, expected_curves): + assert len(acurve) == len(ecurve) + for apt, ept in zip(acurve, ecurve): + assert apt == pytest.approx(ept) + + +def test_splitQuadratic(): + assert splitQuadratic( + (0, 0), (50, 100), (100, 0), where=150, isHorizontal=False + ) == [((0, 0), (50, 100), (100, 0))] + assert splitQuadratic( + (0, 0), (50, 100), (100, 0), where=50, isHorizontal=False + ) == [((0, 0), (25, 50), (50, 50)), + ((50, 50), (75, 50), (100, 0))] + assert splitQuadratic( + (0, 0), (50, 100), (100, 0), where=25, isHorizontal=False + ) == [((0, 0), (12.5, 25), (25, 37.5)), + ((25, 37.5), (62.5, 75), (100, 0))] + assert_curves_approx_equal( + splitQuadratic( + (0, 0), (50, 100), (100, 0), where=25, isHorizontal=True), + [((0, 0), (7.32233, 14.64466), (14.64466, 25)), + ((14.64466, 25), (50, 75), (85.3553, 25)), + ((85.3553, 25), (92.6777, 14.64466), (100, -7.10543e-15))]) + # XXX I'm not at all sure if the following behavior is desirable + assert splitQuadratic( + (0, 0), (50, 100), (100, 0), where=50, isHorizontal=True + ) == [((0, 0), (25, 50), (50, 50)), + ((50, 50), (50, 50), (50, 50)), + ((50, 50), (75, 50), (100, 0))] + + +def test_splitCubic(): + assert splitCubic( + (0, 0), (25, 100), (75, 100), (100, 0), where=150, isHorizontal=False + ) == [((0, 0), (25, 100), (75, 100), (100, 0))] + assert splitCubic( + (0, 0), (25, 100), (75, 100), (100, 0), where=50, isHorizontal=False + ) == [((0, 0), (12.5, 50), (31.25, 75), (50, 75)), + ((50, 75), (68.75, 75), (87.5, 50), (100, 0))] + assert_curves_approx_equal( + splitCubic( + (0, 0), (25, 100), (75, 100), (100, 0), where=25, + isHorizontal=True), + [((0, 0), (2.293792, 9.17517), (4.798045, 17.5085), (7.47414, 25)), + ((7.47414, 25), (31.2886, 91.6667), (68.7114, 91.6667), + (92.5259, 25)), + ((92.5259, 25), (95.202, 17.5085), (97.7062, 9.17517), + (100, 1.77636e-15))]) + + +def test_splitQuadraticAtT(): + assert splitQuadraticAtT( + (0, 0), (50, 100), (100, 0), 0.5 + ) == [((0, 0), (25, 50), (50, 50)), + ((50, 50), (75, 50), (100, 0))] + assert splitQuadraticAtT( + (0, 0), (50, 100), (100, 0), 0.5, 0.75 + ) == [((0, 0), (25, 50), (50, 50)), + ((50, 50), (62.5, 50), (75, 37.5)), + ((75, 37.5), (87.5, 25), (100, 0))] + + +def test_splitCubicAtT(): + assert splitCubicAtT( + (0, 0), (25, 100), (75, 100), (100, 0), 0.5 + ) == [((0, 0), (12.5, 50), (31.25, 75), (50, 75)), + ((50, 75), (68.75, 75), (87.5, 50), (100, 0))] + assert splitCubicAtT( + (0, 0), (25, 100), (75, 100), (100, 0), 0.5, 0.75 + ) == [((0, 0), (12.5, 50), (31.25, 75), (50, 75)), + ((50, 75), (59.375, 75), (68.75, 68.75), (77.34375, 56.25)), + ((77.34375, 56.25), (85.9375, 43.75), (93.75, 25), (100, 0))] + + +def test_solveCubic(): + assert solveCubic(1, 1, -6, 0) == [-3.0, -0.0, 2.0] + assert solveCubic(-10.0, -9.0, 48.0, -29.0) == [-2.9, 1.0, 1.0] + assert solveCubic(-9.875, -9.0, 47.625, -28.75) == [-2.911392, 1.0, 1.0] + assert solveCubic(1.0, -4.5, 6.75, -3.375) == [1.5, 1.5, 1.5] + assert solveCubic(-12.0, 18.0, -9.0, 1.50023651123) == [0.5, 0.5, 0.5] + assert solveCubic(9.0, 0.0, 0.0, -7.62939453125e-05) == [-0.0, -0.0, -0.0] diff --git a/Tests/misc/classifyTools_test.py b/Tests/misc/classifyTools_test.py new file mode 100644 index 000000000..204db60a7 --- /dev/null +++ b/Tests/misc/classifyTools_test.py @@ -0,0 +1,30 @@ +from __future__ import print_function, division, absolute_import +from fontTools.misc.py23 import * +from fontTools.misc.classifyTools import classify + + +def test_classify(): + assert classify([]) == ([], {}) + assert classify([[]]) == ([], {}) + assert classify([[], []]) == ([], {}) + assert classify([[1]]) == ([{1}], {1: {1}}) + assert classify([[1,2]]) == ([{1, 2}], {1: {1, 2}, 2: {1, 2}}) + assert classify([[1],[2]]) == ([{1}, {2}], {1: {1}, 2: {2}}) + assert classify([[1,2],[2]]) == ([{1}, {2}], {1: {1}, 2: {2}}) + assert classify([[1,2],[2,4]]) == ( + [{1}, {4}, {2}], {1: {1}, 2: {2}, 4: {4}}) + assert classify([[1,2],[2,4,5]]) == ( + [{4, 5}, {1}, {2}], {1: {1}, 2: {2}, 4: {4, 5}, 5: {4, 5}}) + assert classify([[1,2],[2,4,5]], sort=False) == ( + [{1}, {4, 5}, {2}], {1: {1}, 2: {2}, 4: {4, 5}, 5: {4, 5}}) + assert classify([[1,2,9],[2,4,5]], sort=False) == ( + [{1, 9}, {4, 5}, {2}], + {1: {1, 9}, 2: {2}, 4: {4, 5}, 5: {4, 5}, 9: {1, 9}}) + assert classify([[1,2,9,15],[2,4,5]], sort=False) == ( + [{1, 9, 15}, {4, 5}, {2}], + {1: {1, 9, 15}, 2: {2}, 4: {4, 5}, 5: {4, 5}, 9: {1, 9, 15}, + 15: {1, 9, 15}}) + classes, mapping = classify([[1,2,9,15],[2,4,5],[15,5]], sort=False) + assert set([frozenset(c) for c in classes]) == set( + [frozenset(s) for s in ({1, 9}, {4}, {2}, {5}, {15})]) + assert mapping == {1: {1, 9}, 2: {2}, 4: {4}, 5: {5}, 9: {1, 9}, 15: {15}} diff --git a/Tests/misc/eexec_test.py b/Tests/misc/eexec_test.py new file mode 100644 index 000000000..204309589 --- /dev/null +++ b/Tests/misc/eexec_test.py @@ -0,0 +1,17 @@ +from __future__ import print_function, division, absolute_import +from fontTools.misc.py23 import * +from fontTools.misc.eexec import decrypt, encrypt + + +def test_decrypt(): + testStr = b"\0\0asdadads asds\265" + decryptedStr, R = decrypt(testStr, 12321) + assert decryptedStr == b'0d\nh\x15\xe8\xc4\xb2\x15\x1d\x108\x1a<6\xa1' + assert R == 36142 + + +def test_encrypt(): + testStr = b'0d\nh\x15\xe8\xc4\xb2\x15\x1d\x108\x1a<6\xa1' + encryptedStr, R = encrypt(testStr, 12321) + assert encryptedStr == b"\0\0asdadads asds\265" + assert R == 36142 diff --git a/Lib/fontTools/misc/encodingTools_test.py b/Tests/misc/encodingTools_test.py similarity index 95% rename from Lib/fontTools/misc/encodingTools_test.py rename to Tests/misc/encodingTools_test.py index 2efaeb0ce..4c9628b7b 100644 --- a/Lib/fontTools/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/Lib/fontTools/misc/fixedTools_test.py b/Tests/misc/fixedTools_test.py similarity index 100% rename from Lib/fontTools/misc/fixedTools_test.py rename to Tests/misc/fixedTools_test.py diff --git a/Tests/misc/loggingTools_test.py b/Tests/misc/loggingTools_test.py new file mode 100644 index 000000000..4ea2b3cba --- /dev/null +++ b/Tests/misc/loggingTools_test.py @@ -0,0 +1,150 @@ +from __future__ import print_function, division, absolute_import +from fontTools.misc.py23 import * +from fontTools.misc.loggingTools import ( + LevelFormatter, Timer, configLogger, ChannelsFilter) +import logging +import textwrap +import time +import re +import pytest + + +def logger_name_generator(): + basename = "fontTools.test#" + num = 1 + while True: + yield basename+str(num) + num += 1 + +unique_logger_name = logger_name_generator() + + +@pytest.fixture +def logger(): + log = logging.getLogger(next(unique_logger_name)) + configLogger(logger=log, level="DEBUG", stream=StringIO()) + return log + + +def test_LevelFormatter(): + stream = StringIO() + handler = logging.StreamHandler(stream) + formatter = LevelFormatter( + fmt={ + '*': '[%(levelname)s] %(message)s', + 'DEBUG': '%(name)s [%(levelname)s] %(message)s', + 'INFO': '%(message)s', + }) + handler.setFormatter(formatter) + name = next(unique_logger_name) + log = logging.getLogger(name) + log.setLevel(logging.DEBUG) + log.addHandler(handler) + + log.debug("this uses a custom format string") + log.info("this also uses a custom format string") + log.warning("this one uses the default format string") + + assert stream.getvalue() == textwrap.dedent("""\ + %s [DEBUG] this uses a custom format string + this also uses a custom format string + [WARNING] this one uses the default format string + """ % name) + + +class TimerTest(object): + + def test_split(self): + timer = Timer() + time.sleep(0.01) + fist_lap = timer.split() + assert timer.elapsed == fist_lap + time.sleep(0.02) + second_lap = timer.split() + assert second_lap > fist_lap + assert timer.elapsed == second_lap + + def test_time(self): + timer = Timer() + time.sleep(0.01) + overall_time = timer.time() + assert overall_time > 0 + + def test_context_manager(self): + with Timer() as t: + time.sleep(0.01) + assert t.elapsed > 0 + + def test_using_logger(self, logger): + with Timer(logger, 'do something'): + time.sleep(0.01) + + assert re.match( + "Took [0-9]\.[0-9]{3}s to do something", + logger.handlers[0].stream.getvalue()) + + def test_using_logger_calling_instance(self, logger): + timer = Timer(logger) + with timer(): + time.sleep(0.01) + + assert re.match( + "elapsed time: [0-9]\.[0-9]{3}s", + logger.handlers[0].stream.getvalue()) + + # do it again but with custom level + with timer('redo it', level=logging.WARNING): + time.sleep(0.02) + + assert re.search( + "WARNING: Took [0-9]\.[0-9]{3}s to redo it", + logger.handlers[0].stream.getvalue()) + + def test_function_decorator(self, logger): + timer = Timer(logger) + + @timer() + def test1(): + time.sleep(0.01) + @timer('run test 2', level=logging.INFO) + def test2(): + time.sleep(0.02) + + test1() + + assert re.match( + "Took [0-9]\.[0-9]{3}s to run 'test1'", + logger.handlers[0].stream.getvalue()) + + test2() + + assert re.search( + "Took [0-9]\.[0-9]{3}s to run test 2", + logger.handlers[0].stream.getvalue()) + + +def test_ChannelsFilter(logger): + n = logger.name + filtr = ChannelsFilter(n+".A.B", n+".C.D") + handler = logger.handlers[0] + handler.addFilter(filtr) + stream = handler.stream + + logging.getLogger(n+".A.B").debug('this record passes through') + assert 'this record passes through' in stream.getvalue() + + logging.getLogger(n+'.A.B.C').debug('records from children also pass') + assert 'records from children also pass' in stream.getvalue() + + logging.getLogger(n+'.C.D').debug('this one as well') + assert 'this one as well' in stream.getvalue() + + logging.getLogger(n+'.A.B.').debug('also this one') + assert 'also this one' in stream.getvalue() + + before = stream.getvalue() + logging.getLogger(n+'.A.F').debug('but this one does not!') + assert before == stream.getvalue() + + logging.getLogger(n+'.C.DE').debug('neither this one!') + assert before == stream.getvalue() diff --git a/Lib/fontTools/misc/macRes_test.py b/Tests/misc/macRes_test.py similarity index 98% rename from Lib/fontTools/misc/macRes_test.py rename to Tests/misc/macRes_test.py index feaa33e57..fde13f87f 100644 --- a/Lib/fontTools/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/Lib/fontTools/misc/py23_test.py b/Tests/misc/py23_test.py similarity index 95% rename from Lib/fontTools/misc/py23_test.py rename to Tests/misc/py23_test.py index 6c5355239..c2be03691 100644 --- a/Lib/fontTools/misc/py23_test.py +++ b/Tests/misc/py23_test.py @@ -389,5 +389,34 @@ class IsCloseTests(unittest.TestCase): self.assertAllNotClose(fraction_examples, rel_tol=1e-9) +@unittest.skipUnless( + (sys.version_info[0] == 2 and sys.maxunicode < 0x10FFFF), + "requires 'narrow' Python 2.7 build") +class NarrowUnicodeBuildTest(unittest.TestCase): + + def test_unichr(self): + from __builtin__ import unichr as narrow_unichr + + self.assertRaises( + ValueError, + narrow_unichr, 0xFFFF + 1) + + self.assertEqual(unichr(1114111), u'\U0010FFFF') + + self.assertRaises( + ValueError, + unichr, 0x10FFFF + 1) + + def test_byteord(self): + from __builtin__ import ord as narrow_ord + + self.assertRaises( + TypeError, + narrow_ord, u'\U00010000') + + self.assertEqual(byteord(u'\U00010000'), 0xFFFF + 1) + self.assertEqual(byteord(u'\U0010FFFF'), 1114111) + + if __name__ == "__main__": sys.exit(unittest.main()) diff --git a/Lib/fontTools/misc/testTools_test.py b/Tests/misc/testTools_test.py similarity index 100% rename from Lib/fontTools/misc/testTools_test.py rename to Tests/misc/testTools_test.py diff --git a/Tests/misc/textTools_test.py b/Tests/misc/textTools_test.py new file mode 100644 index 000000000..547569afc --- /dev/null +++ b/Tests/misc/textTools_test.py @@ -0,0 +1,11 @@ +from __future__ import print_function, division, absolute_import +from fontTools.misc.py23 import * +from fontTools.misc.textTools import pad + + +def test_pad(): + assert len(pad(b'abcd', 4)) == 4 + assert len(pad(b'abcde', 2)) == 6 + assert len(pad(b'abcde', 4)) == 8 + assert pad(b'abcdef', 4) == b'abcdef\x00\x00' + assert pad(b'abcdef', 1) == b'abcdef' diff --git a/Tests/misc/timeTools_test.py b/Tests/misc/timeTools_test.py new file mode 100644 index 000000000..e5da19b05 --- /dev/null +++ b/Tests/misc/timeTools_test.py @@ -0,0 +1,9 @@ +from __future__ import print_function, division, absolute_import +from fontTools.misc.py23 import * +from fontTools.misc.timeTools import asctime +import time + + +def test_asctime(): + assert isinstance(asctime(), basestring) + assert asctime(time.gmtime(0)) == 'Thu Jan 1 00:00:00 1970' diff --git a/Tests/misc/transform_test.py b/Tests/misc/transform_test.py new file mode 100644 index 000000000..7a7a67dca --- /dev/null +++ b/Tests/misc/transform_test.py @@ -0,0 +1,101 @@ +from __future__ import print_function, division, absolute_import +from fontTools.misc.py23 import * +from fontTools.misc.transform import Transform, Identity, Offset, Scale +import math +import pytest + + +class TransformTest(object): + + def test_examples(self): + t = Transform() + assert repr(t) == "" + assert t.scale(2) == Transform(2, 0, 0, 2, 0, 0) + assert t.scale(2.5, 5.5) == Transform(2.5, 0, 0, 5.5, 0, 0) + assert t.scale(2, 3).transformPoint((100, 100)) == (200, 300) + + def test__init__(self): + assert Transform(12) == Transform(12, 0, 0, 1, 0, 0) + assert Transform(dx=12) == Transform(1, 0, 0, 1, 12, 0) + assert Transform(yx=12) == Transform(1, 0, 12, 1, 0, 0) + + def test_transformPoints(self): + t = Transform(2, 0, 0, 3, 0, 0) + assert t.transformPoints( + [(0, 0), (0, 100), (100, 100), (100, 0)] + ) == [(0, 0), (0, 300), (200, 300), (200, 0)] + + def test_translate(self): + t = Transform() + assert t.translate(20, 30) == Transform(1, 0, 0, 1, 20, 30) + + def test_scale(self): + t = Transform() + assert t.scale(5) == Transform(5, 0, 0, 5, 0, 0) + assert t.scale(5, 6) == Transform(5, 0, 0, 6, 0, 0) + + def test_rotate(self): + t = Transform() + assert t.rotate(math.pi / 2) == Transform(0, 1, -1, 0, 0, 0) + t = Transform() + assert t.rotate(-math.pi / 2) == Transform(0, -1, 1, 0, 0, 0) + t = Transform() + assert tuple(t.rotate(math.radians(30))) == pytest.approx( + tuple(Transform(0.866025, 0.5, -0.5, 0.866025, 0, 0))) + + def test_skew(self): + t = Transform().skew(math.pi / 4) + assert tuple(t) == pytest.approx(tuple(Transform(1, 0, 1, 1, 0, 0))) + + def test_transform(self): + t = Transform(2, 0, 0, 3, 1, 6) + assert t.transform((4, 3, 2, 1, 5, 6)) == Transform(8, 9, 4, 3, 11, 24) + + def test_reverseTransform(self): + t = Transform(2, 0, 0, 3, 1, 6) + reverse_t = t.reverseTransform((4, 3, 2, 1, 5, 6)) + assert reverse_t == Transform(8, 6, 6, 3, 21, 15) + t = Transform(4, 3, 2, 1, 5, 6) + reverse_t = t.transform((2, 0, 0, 3, 1, 6)) + assert reverse_t == Transform(8, 6, 6, 3, 21, 15) + + def test_inverse(self): + t = Transform().translate(2, 3).scale(4, 5) + assert t.transformPoint((10, 20)) == (42, 103) + it = t.inverse() + assert it.transformPoint((42, 103)) == (10.0, 20.0) + assert Transform().inverse() == Transform() + + def test_toPS(self): + t = Transform().scale(2, 3).translate(4, 5) + assert t.toPS() == '[2 0 0 3 8 15]' + + def test__ne__(self): + assert Transform() != Transform(2, 0, 0, 2, 0, 0) + + def test__hash__(self): + t = Transform(12, 0, 0, 13, 0, 0) + d = {t: None} + assert t in d.keys() + + def test__bool__(self): + assert not bool(Transform()) + assert Transform(2, 0, 0, 2, 0, 0) + assert Transform(1, 0, 0, 1, 1, 0) + + def test__repr__(self): + assert repr(Transform(1, 2, 3, 4, 5, 6)) == '' + + def test_Identity(self): + assert isinstance(Identity, Transform) + assert Identity == Transform(1, 0, 0, 1, 0, 0) + + def test_Offset(self): + assert Offset() == Transform(1, 0, 0, 1, 0, 0) + assert Offset(1) == Transform(1, 0, 0, 1, 1, 0) + assert Offset(1, 2) == Transform(1, 0, 0, 1, 1, 2) + + def test_Scale(self): + assert Scale(1) == Transform(1, 0, 0, 1, 0, 0) + assert Scale(2) == Transform(2, 0, 0, 2, 0, 0) + assert Scale(1, 2) == Transform(1, 0, 0, 2, 0, 0) diff --git a/Lib/fontTools/misc/xmlReader_test.py b/Tests/misc/xmlReader_test.py similarity index 98% rename from Lib/fontTools/misc/xmlReader_test.py rename to Tests/misc/xmlReader_test.py index a2c9aa2c8..622abf5cd 100644 --- a/Lib/fontTools/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/Lib/fontTools/misc/xmlWriter_test.py b/Tests/misc/xmlWriter_test.py similarity index 98% rename from Lib/fontTools/misc/xmlWriter_test.py rename to Tests/misc/xmlWriter_test.py index 3ee63c63c..0930e1cec 100644 --- a/Lib/fontTools/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/Lib/fontTools/mtiLib/testdata/featurename-backward.ttx.GSUB b/Tests/mtiLib/data/featurename-backward.ttx.GSUB similarity index 100% rename from Lib/fontTools/mtiLib/testdata/featurename-backward.ttx.GSUB rename to Tests/mtiLib/data/featurename-backward.ttx.GSUB diff --git a/Lib/fontTools/mtiLib/testdata/featurename-backward.txt b/Tests/mtiLib/data/featurename-backward.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/featurename-backward.txt rename to Tests/mtiLib/data/featurename-backward.txt diff --git a/Lib/fontTools/mtiLib/testdata/featurename-forward.ttx.GSUB b/Tests/mtiLib/data/featurename-forward.ttx.GSUB similarity index 100% rename from Lib/fontTools/mtiLib/testdata/featurename-forward.ttx.GSUB rename to Tests/mtiLib/data/featurename-forward.ttx.GSUB diff --git a/Lib/fontTools/mtiLib/testdata/featurename-forward.txt b/Tests/mtiLib/data/featurename-forward.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/featurename-forward.txt rename to Tests/mtiLib/data/featurename-forward.txt diff --git a/Lib/fontTools/mtiLib/testdata/lookupnames-backward.ttx.GSUB b/Tests/mtiLib/data/lookupnames-backward.ttx.GSUB similarity index 100% rename from Lib/fontTools/mtiLib/testdata/lookupnames-backward.ttx.GSUB rename to Tests/mtiLib/data/lookupnames-backward.ttx.GSUB diff --git a/Lib/fontTools/mtiLib/testdata/lookupnames-backward.txt b/Tests/mtiLib/data/lookupnames-backward.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/lookupnames-backward.txt rename to Tests/mtiLib/data/lookupnames-backward.txt diff --git a/Lib/fontTools/mtiLib/testdata/lookupnames-forward.ttx.GSUB b/Tests/mtiLib/data/lookupnames-forward.ttx.GSUB similarity index 100% rename from Lib/fontTools/mtiLib/testdata/lookupnames-forward.ttx.GSUB rename to Tests/mtiLib/data/lookupnames-forward.ttx.GSUB diff --git a/Lib/fontTools/mtiLib/testdata/lookupnames-forward.txt b/Tests/mtiLib/data/lookupnames-forward.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/lookupnames-forward.txt rename to Tests/mtiLib/data/lookupnames-forward.txt diff --git a/Lib/fontTools/mtiLib/testdata/mixed-toplevels.ttx.GSUB b/Tests/mtiLib/data/mixed-toplevels.ttx.GSUB similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mixed-toplevels.ttx.GSUB rename to Tests/mtiLib/data/mixed-toplevels.ttx.GSUB diff --git a/Lib/fontTools/mtiLib/testdata/mixed-toplevels.txt b/Tests/mtiLib/data/mixed-toplevels.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mixed-toplevels.txt rename to Tests/mtiLib/data/mixed-toplevels.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/README b/Tests/mtiLib/data/mti/README similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/README rename to Tests/mtiLib/data/mti/README diff --git a/Lib/fontTools/mtiLib/testdata/mti/chained-glyph.ttx.GPOS b/Tests/mtiLib/data/mti/chained-glyph.ttx.GPOS similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/chained-glyph.ttx.GPOS rename to Tests/mtiLib/data/mti/chained-glyph.ttx.GPOS diff --git a/Lib/fontTools/mtiLib/testdata/mti/chained-glyph.ttx.GSUB b/Tests/mtiLib/data/mti/chained-glyph.ttx.GSUB similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/chained-glyph.ttx.GSUB rename to Tests/mtiLib/data/mti/chained-glyph.ttx.GSUB diff --git a/Lib/fontTools/mtiLib/testdata/mti/chained-glyph.txt b/Tests/mtiLib/data/mti/chained-glyph.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/chained-glyph.txt rename to Tests/mtiLib/data/mti/chained-glyph.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/chainedclass.ttx.GSUB b/Tests/mtiLib/data/mti/chainedclass.ttx.GSUB similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/chainedclass.ttx.GSUB rename to Tests/mtiLib/data/mti/chainedclass.ttx.GSUB diff --git a/Lib/fontTools/mtiLib/testdata/mti/chainedclass.txt b/Tests/mtiLib/data/mti/chainedclass.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/chainedclass.txt rename to Tests/mtiLib/data/mti/chainedclass.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/chainedcoverage.ttx.GSUB b/Tests/mtiLib/data/mti/chainedcoverage.ttx.GSUB similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/chainedcoverage.ttx.GSUB rename to Tests/mtiLib/data/mti/chainedcoverage.ttx.GSUB diff --git a/Lib/fontTools/mtiLib/testdata/mti/chainedcoverage.txt b/Tests/mtiLib/data/mti/chainedcoverage.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/chainedcoverage.txt rename to Tests/mtiLib/data/mti/chainedcoverage.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/cmap.ttx b/Tests/mtiLib/data/mti/cmap.ttx similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/cmap.ttx rename to Tests/mtiLib/data/mti/cmap.ttx diff --git a/Lib/fontTools/mtiLib/testdata/mti/cmap.ttx.cmap b/Tests/mtiLib/data/mti/cmap.ttx.cmap similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/cmap.ttx.cmap rename to Tests/mtiLib/data/mti/cmap.ttx.cmap diff --git a/Lib/fontTools/mtiLib/testdata/mti/cmap.txt b/Tests/mtiLib/data/mti/cmap.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/cmap.txt rename to Tests/mtiLib/data/mti/cmap.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/context-glyph.txt b/Tests/mtiLib/data/mti/context-glyph.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/context-glyph.txt rename to Tests/mtiLib/data/mti/context-glyph.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/contextclass.txt b/Tests/mtiLib/data/mti/contextclass.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/contextclass.txt rename to Tests/mtiLib/data/mti/contextclass.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/contextcoverage.txt b/Tests/mtiLib/data/mti/contextcoverage.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/contextcoverage.txt rename to Tests/mtiLib/data/mti/contextcoverage.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/featuretable.txt b/Tests/mtiLib/data/mti/featuretable.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/featuretable.txt rename to Tests/mtiLib/data/mti/featuretable.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/gdefattach.ttx.GDEF b/Tests/mtiLib/data/mti/gdefattach.ttx.GDEF similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gdefattach.ttx.GDEF rename to Tests/mtiLib/data/mti/gdefattach.ttx.GDEF diff --git a/Lib/fontTools/mtiLib/testdata/mti/gdefattach.txt b/Tests/mtiLib/data/mti/gdefattach.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gdefattach.txt rename to Tests/mtiLib/data/mti/gdefattach.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/gdefclasses.ttx.GDEF b/Tests/mtiLib/data/mti/gdefclasses.ttx.GDEF similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gdefclasses.ttx.GDEF rename to Tests/mtiLib/data/mti/gdefclasses.ttx.GDEF diff --git a/Lib/fontTools/mtiLib/testdata/mti/gdefclasses.txt b/Tests/mtiLib/data/mti/gdefclasses.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gdefclasses.txt rename to Tests/mtiLib/data/mti/gdefclasses.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/gdefligcaret.ttx.GDEF b/Tests/mtiLib/data/mti/gdefligcaret.ttx.GDEF similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gdefligcaret.ttx.GDEF rename to Tests/mtiLib/data/mti/gdefligcaret.ttx.GDEF diff --git a/Lib/fontTools/mtiLib/testdata/mti/gdefligcaret.txt b/Tests/mtiLib/data/mti/gdefligcaret.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gdefligcaret.txt rename to Tests/mtiLib/data/mti/gdefligcaret.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/gdefmarkattach.ttx.GDEF b/Tests/mtiLib/data/mti/gdefmarkattach.ttx.GDEF similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gdefmarkattach.ttx.GDEF rename to Tests/mtiLib/data/mti/gdefmarkattach.ttx.GDEF diff --git a/Lib/fontTools/mtiLib/testdata/mti/gdefmarkattach.txt b/Tests/mtiLib/data/mti/gdefmarkattach.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gdefmarkattach.txt rename to Tests/mtiLib/data/mti/gdefmarkattach.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/gdefmarkfilter.ttx.GDEF b/Tests/mtiLib/data/mti/gdefmarkfilter.ttx.GDEF similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gdefmarkfilter.ttx.GDEF rename to Tests/mtiLib/data/mti/gdefmarkfilter.ttx.GDEF diff --git a/Lib/fontTools/mtiLib/testdata/mti/gdefmarkfilter.txt b/Tests/mtiLib/data/mti/gdefmarkfilter.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gdefmarkfilter.txt rename to Tests/mtiLib/data/mti/gdefmarkfilter.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/gposcursive.ttx.GPOS b/Tests/mtiLib/data/mti/gposcursive.ttx.GPOS similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gposcursive.ttx.GPOS rename to Tests/mtiLib/data/mti/gposcursive.ttx.GPOS diff --git a/Lib/fontTools/mtiLib/testdata/mti/gposcursive.txt b/Tests/mtiLib/data/mti/gposcursive.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gposcursive.txt rename to Tests/mtiLib/data/mti/gposcursive.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/gposkernset.ttx.GPOS b/Tests/mtiLib/data/mti/gposkernset.ttx.GPOS similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gposkernset.ttx.GPOS rename to Tests/mtiLib/data/mti/gposkernset.ttx.GPOS diff --git a/Lib/fontTools/mtiLib/testdata/mti/gposkernset.txt b/Tests/mtiLib/data/mti/gposkernset.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gposkernset.txt rename to Tests/mtiLib/data/mti/gposkernset.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/gposmarktobase.ttx.GPOS b/Tests/mtiLib/data/mti/gposmarktobase.ttx.GPOS similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gposmarktobase.ttx.GPOS rename to Tests/mtiLib/data/mti/gposmarktobase.ttx.GPOS diff --git a/Lib/fontTools/mtiLib/testdata/mti/gposmarktobase.txt b/Tests/mtiLib/data/mti/gposmarktobase.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gposmarktobase.txt rename to Tests/mtiLib/data/mti/gposmarktobase.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/gpospairclass.ttx.GPOS b/Tests/mtiLib/data/mti/gpospairclass.ttx.GPOS similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gpospairclass.ttx.GPOS rename to Tests/mtiLib/data/mti/gpospairclass.ttx.GPOS diff --git a/Lib/fontTools/mtiLib/testdata/mti/gpospairclass.txt b/Tests/mtiLib/data/mti/gpospairclass.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gpospairclass.txt rename to Tests/mtiLib/data/mti/gpospairclass.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/gpospairglyph.ttx.GPOS b/Tests/mtiLib/data/mti/gpospairglyph.ttx.GPOS similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gpospairglyph.ttx.GPOS rename to Tests/mtiLib/data/mti/gpospairglyph.ttx.GPOS diff --git a/Lib/fontTools/mtiLib/testdata/mti/gpospairglyph.txt b/Tests/mtiLib/data/mti/gpospairglyph.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gpospairglyph.txt rename to Tests/mtiLib/data/mti/gpospairglyph.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/gpossingle.ttx.GPOS b/Tests/mtiLib/data/mti/gpossingle.ttx.GPOS similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gpossingle.ttx.GPOS rename to Tests/mtiLib/data/mti/gpossingle.ttx.GPOS diff --git a/Lib/fontTools/mtiLib/testdata/mti/gpossingle.txt b/Tests/mtiLib/data/mti/gpossingle.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gpossingle.txt rename to Tests/mtiLib/data/mti/gpossingle.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/gsubalternate.ttx.GSUB b/Tests/mtiLib/data/mti/gsubalternate.ttx.GSUB similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gsubalternate.ttx.GSUB rename to Tests/mtiLib/data/mti/gsubalternate.ttx.GSUB diff --git a/Lib/fontTools/mtiLib/testdata/mti/gsubalternate.txt b/Tests/mtiLib/data/mti/gsubalternate.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gsubalternate.txt rename to Tests/mtiLib/data/mti/gsubalternate.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/gsubligature.ttx.GSUB b/Tests/mtiLib/data/mti/gsubligature.ttx.GSUB similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gsubligature.ttx.GSUB rename to Tests/mtiLib/data/mti/gsubligature.ttx.GSUB diff --git a/Lib/fontTools/mtiLib/testdata/mti/gsubligature.txt b/Tests/mtiLib/data/mti/gsubligature.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gsubligature.txt rename to Tests/mtiLib/data/mti/gsubligature.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/gsubmultiple.ttx.GSUB b/Tests/mtiLib/data/mti/gsubmultiple.ttx.GSUB similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gsubmultiple.ttx.GSUB rename to Tests/mtiLib/data/mti/gsubmultiple.ttx.GSUB diff --git a/Lib/fontTools/mtiLib/testdata/mti/gsubmultiple.txt b/Tests/mtiLib/data/mti/gsubmultiple.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gsubmultiple.txt rename to Tests/mtiLib/data/mti/gsubmultiple.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/gsubreversechanined.ttx.GSUB b/Tests/mtiLib/data/mti/gsubreversechanined.ttx.GSUB similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gsubreversechanined.ttx.GSUB rename to Tests/mtiLib/data/mti/gsubreversechanined.ttx.GSUB diff --git a/Lib/fontTools/mtiLib/testdata/mti/gsubreversechanined.txt b/Tests/mtiLib/data/mti/gsubreversechanined.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gsubreversechanined.txt rename to Tests/mtiLib/data/mti/gsubreversechanined.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/gsubsingle.ttx.GSUB b/Tests/mtiLib/data/mti/gsubsingle.ttx.GSUB similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gsubsingle.ttx.GSUB rename to Tests/mtiLib/data/mti/gsubsingle.ttx.GSUB diff --git a/Lib/fontTools/mtiLib/testdata/mti/gsubsingle.txt b/Tests/mtiLib/data/mti/gsubsingle.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/gsubsingle.txt rename to Tests/mtiLib/data/mti/gsubsingle.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/mark-to-ligature.ttx.GPOS b/Tests/mtiLib/data/mti/mark-to-ligature.ttx.GPOS similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/mark-to-ligature.ttx.GPOS rename to Tests/mtiLib/data/mti/mark-to-ligature.ttx.GPOS diff --git a/Lib/fontTools/mtiLib/testdata/mti/mark-to-ligature.txt b/Tests/mtiLib/data/mti/mark-to-ligature.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/mark-to-ligature.txt rename to Tests/mtiLib/data/mti/mark-to-ligature.txt diff --git a/Lib/fontTools/mtiLib/testdata/mti/scripttable.ttx.GPOS b/Tests/mtiLib/data/mti/scripttable.ttx.GPOS similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/scripttable.ttx.GPOS rename to Tests/mtiLib/data/mti/scripttable.ttx.GPOS diff --git a/Lib/fontTools/mtiLib/testdata/mti/scripttable.ttx.GSUB b/Tests/mtiLib/data/mti/scripttable.ttx.GSUB similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/scripttable.ttx.GSUB rename to Tests/mtiLib/data/mti/scripttable.ttx.GSUB diff --git a/Lib/fontTools/mtiLib/testdata/mti/scripttable.txt b/Tests/mtiLib/data/mti/scripttable.txt similarity index 100% rename from Lib/fontTools/mtiLib/testdata/mti/scripttable.txt rename to Tests/mtiLib/data/mti/scripttable.txt diff --git a/Lib/fontTools/mtiLib/mti_test.py b/Tests/mtiLib/mti_test.py similarity index 98% rename from Lib/fontTools/mtiLib/mti_test.py rename to Tests/mtiLib/mti_test.py index ce9e6e67b..491682868 100644 --- a/Lib/fontTools/mtiLib/mti_test.py +++ b/Tests/mtiLib/mti_test.py @@ -75,7 +75,7 @@ class MtiTest(unittest.TestCase): 'exclam', 'quotedbl', 'numbersign', ] - # Feature files in testdata/*.txt; output gets compared to testdata/*.ttx. + # Feature files in data/*.txt; output gets compared to data/*.ttx. TESTS = { None: ( 'mti/cmap', @@ -143,7 +143,7 @@ class MtiTest(unittest.TestCase): @staticmethod def getpath(testfile): path, _ = os.path.split(__file__) - return os.path.join(path, "testdata", testfile) + return os.path.join(path, "data", testfile) def expect_ttx(self, expected_ttx, actual_ttx, fromfile=None, tofile=None): expected = [l+'\n' for l in expected_ttx.split('\n')] diff --git a/Lib/fontTools/otlLib/builder_test.py b/Tests/otlLib/builder_test.py similarity index 100% rename from Lib/fontTools/otlLib/builder_test.py rename to Tests/otlLib/builder_test.py diff --git a/Lib/fontTools/pens/areaPen_test.py b/Tests/pens/areaPen_test.py similarity index 100% rename from Lib/fontTools/pens/areaPen_test.py rename to Tests/pens/areaPen_test.py diff --git a/Lib/fontTools/pens/basePen_test.py b/Tests/pens/basePen_test.py similarity index 100% rename from Lib/fontTools/pens/basePen_test.py rename to Tests/pens/basePen_test.py diff --git a/Lib/fontTools/pens/boundsPen_test.py b/Tests/pens/boundsPen_test.py similarity index 100% rename from Lib/fontTools/pens/boundsPen_test.py rename to Tests/pens/boundsPen_test.py diff --git a/Lib/fontTools/pens/perimeterPen_test.py b/Tests/pens/perimeterPen_test.py similarity index 100% rename from Lib/fontTools/pens/perimeterPen_test.py rename to Tests/pens/perimeterPen_test.py diff --git a/Lib/fontTools/pens/pointInsidePen_test.py b/Tests/pens/pointInsidePen_test.py similarity index 100% rename from Lib/fontTools/pens/pointInsidePen_test.py rename to Tests/pens/pointInsidePen_test.py diff --git a/Lib/fontTools/pens/t2CharStringPen_test.py b/Tests/pens/t2CharStringPen_test.py similarity index 100% rename from Lib/fontTools/pens/t2CharStringPen_test.py rename to Tests/pens/t2CharStringPen_test.py diff --git a/Lib/fontTools/pens/ttGlyphPen_test.py b/Tests/pens/ttGlyphPen_test.py similarity index 98% rename from Lib/fontTools/pens/ttGlyphPen_test.py rename to Tests/pens/ttGlyphPen_test.py index 024fa4e21..328773eff 100644 --- a/Lib/fontTools/pens/ttGlyphPen_test.py +++ b/Tests/pens/ttGlyphPen_test.py @@ -14,7 +14,7 @@ class TTGlyphPenTest(unittest.TestCase): font = ttLib.TTFont() ttx_path = os.path.join( os.path.abspath(os.path.dirname(os.path.realpath(__file__))), - '..', 'ttLib', 'testdata', filename) + '..', 'ttLib', 'data', filename) font.importXML(ttx_path) glyphSet = font.getGlyphSet() diff --git a/Lib/fontTools/subset/testdata/TestCID-Regular.ttx b/Tests/subset/data/TestCID-Regular.ttx similarity index 100% rename from Lib/fontTools/subset/testdata/TestCID-Regular.ttx rename to Tests/subset/data/TestCID-Regular.ttx diff --git a/Lib/fontTools/subset/testdata/TestCLR-Regular.ttx b/Tests/subset/data/TestCLR-Regular.ttx similarity index 100% rename from Lib/fontTools/subset/testdata/TestCLR-Regular.ttx rename to Tests/subset/data/TestCLR-Regular.ttx diff --git a/Lib/fontTools/subset/testdata/TestGVAR.ttx b/Tests/subset/data/TestGVAR.ttx similarity index 100% rename from Lib/fontTools/subset/testdata/TestGVAR.ttx rename to Tests/subset/data/TestGVAR.ttx diff --git a/Lib/fontTools/subset/testdata/TestMATH-Regular.ttx b/Tests/subset/data/TestMATH-Regular.ttx similarity index 100% rename from Lib/fontTools/subset/testdata/TestMATH-Regular.ttx rename to Tests/subset/data/TestMATH-Regular.ttx diff --git a/Lib/fontTools/subset/testdata/TestOTF-Regular.ttx b/Tests/subset/data/TestOTF-Regular.ttx similarity index 100% rename from Lib/fontTools/subset/testdata/TestOTF-Regular.ttx rename to Tests/subset/data/TestOTF-Regular.ttx diff --git a/Lib/fontTools/subset/testdata/TestTTF-Regular.ttx b/Tests/subset/data/TestTTF-Regular.ttx similarity index 100% rename from Lib/fontTools/subset/testdata/TestTTF-Regular.ttx rename to Tests/subset/data/TestTTF-Regular.ttx diff --git a/Lib/fontTools/subset/testdata/TestTTF-Regular_non_BMP_char.ttx b/Tests/subset/data/TestTTF-Regular_non_BMP_char.ttx similarity index 100% rename from Lib/fontTools/subset/testdata/TestTTF-Regular_non_BMP_char.ttx rename to Tests/subset/data/TestTTF-Regular_non_BMP_char.ttx diff --git a/Lib/fontTools/subset/testdata/expect_keep_colr.ttx b/Tests/subset/data/expect_keep_colr.ttx similarity index 100% rename from Lib/fontTools/subset/testdata/expect_keep_colr.ttx rename to Tests/subset/data/expect_keep_colr.ttx diff --git a/Lib/fontTools/subset/testdata/expect_keep_gvar.ttx b/Tests/subset/data/expect_keep_gvar.ttx similarity index 100% rename from Lib/fontTools/subset/testdata/expect_keep_gvar.ttx rename to Tests/subset/data/expect_keep_gvar.ttx diff --git a/Lib/fontTools/subset/testdata/expect_keep_gvar_notdef_outline.ttx b/Tests/subset/data/expect_keep_gvar_notdef_outline.ttx similarity index 100% rename from Lib/fontTools/subset/testdata/expect_keep_gvar_notdef_outline.ttx rename to Tests/subset/data/expect_keep_gvar_notdef_outline.ttx diff --git a/Lib/fontTools/subset/testdata/expect_keep_math.ttx b/Tests/subset/data/expect_keep_math.ttx similarity index 100% rename from Lib/fontTools/subset/testdata/expect_keep_math.ttx rename to Tests/subset/data/expect_keep_math.ttx diff --git a/Lib/fontTools/subset/testdata/expect_no_notdef_outline_cid.ttx b/Tests/subset/data/expect_no_notdef_outline_cid.ttx similarity index 100% rename from Lib/fontTools/subset/testdata/expect_no_notdef_outline_cid.ttx rename to Tests/subset/data/expect_no_notdef_outline_cid.ttx diff --git a/Lib/fontTools/subset/testdata/expect_no_notdef_outline_otf.ttx b/Tests/subset/data/expect_no_notdef_outline_otf.ttx similarity index 100% rename from Lib/fontTools/subset/testdata/expect_no_notdef_outline_otf.ttx rename to Tests/subset/data/expect_no_notdef_outline_otf.ttx diff --git a/Lib/fontTools/subset/testdata/expect_no_notdef_outline_ttf.ttx b/Tests/subset/data/expect_no_notdef_outline_ttf.ttx similarity index 100% rename from Lib/fontTools/subset/testdata/expect_no_notdef_outline_ttf.ttx rename to Tests/subset/data/expect_no_notdef_outline_ttf.ttx diff --git a/Lib/fontTools/subset/testdata/google_color.ttx b/Tests/subset/data/google_color.ttx similarity index 100% rename from Lib/fontTools/subset/testdata/google_color.ttx rename to Tests/subset/data/google_color.ttx diff --git a/Lib/fontTools/subset/subset_test.py b/Tests/subset/subset_test.py similarity index 99% rename from Lib/fontTools/subset/subset_test.py rename to Tests/subset/subset_test.py index 70e6a123d..d0dd320a1 100644 --- a/Lib/fontTools/subset/subset_test.py +++ b/Tests/subset/subset_test.py @@ -31,7 +31,7 @@ class SubsetTest(unittest.TestCase): @staticmethod def getpath(testfile): path, _ = os.path.split(__file__) - return os.path.join(path, "testdata", testfile) + return os.path.join(path, "data", testfile) def temp_path(self, suffix): if not self.tempdir: diff --git a/Lib/fontTools/t1Lib/testdata/TestT1-Regular.lwfn b/Tests/t1Lib/data/TestT1-Regular.lwfn similarity index 100% rename from Lib/fontTools/t1Lib/testdata/TestT1-Regular.lwfn rename to Tests/t1Lib/data/TestT1-Regular.lwfn diff --git a/Lib/fontTools/t1Lib/testdata/TestT1-Regular.pfa b/Tests/t1Lib/data/TestT1-Regular.pfa similarity index 100% rename from Lib/fontTools/t1Lib/testdata/TestT1-Regular.pfa rename to Tests/t1Lib/data/TestT1-Regular.pfa diff --git a/Lib/fontTools/t1Lib/testdata/TestT1-Regular.pfb b/Tests/t1Lib/data/TestT1-Regular.pfb similarity index 100% rename from Lib/fontTools/t1Lib/testdata/TestT1-Regular.pfb rename to Tests/t1Lib/data/TestT1-Regular.pfb diff --git a/Lib/fontTools/t1Lib/t1Lib_test.py b/Tests/t1Lib/t1Lib_test.py similarity index 98% rename from Lib/fontTools/t1Lib/t1Lib_test.py rename to Tests/t1Lib/t1Lib_test.py index b07eb127b..0e0fcbe35 100644 --- a/Lib/fontTools/t1Lib/t1Lib_test.py +++ b/Tests/t1Lib/t1Lib_test.py @@ -8,7 +8,7 @@ import random CWD = os.path.abspath(os.path.dirname(__file__)) -DATADIR = os.path.join(CWD, 'testdata') +DATADIR = os.path.join(CWD, 'data') # I used `tx` to convert PFA to LWFN (stored in the data fork) LWFN = os.path.join(DATADIR, 'TestT1-Regular.lwfn') PFA = os.path.join(DATADIR, 'TestT1-Regular.pfa') diff --git a/Lib/fontTools/ttLib/testdata/TestOTF-Regular.otx b/Tests/ttLib/data/TestOTF-Regular.otx similarity index 100% rename from Lib/fontTools/ttLib/testdata/TestOTF-Regular.otx rename to Tests/ttLib/data/TestOTF-Regular.otx diff --git a/Lib/fontTools/ttLib/testdata/TestTTF-Regular.ttx b/Tests/ttLib/data/TestTTF-Regular.ttx similarity index 100% rename from Lib/fontTools/ttLib/testdata/TestTTF-Regular.ttx rename to Tests/ttLib/data/TestTTF-Regular.ttx diff --git a/Lib/fontTools/ttLib/testdata/TestTTFComplex-Regular.ttx b/Tests/ttLib/data/TestTTFComplex-Regular.ttx similarity index 100% rename from Lib/fontTools/ttLib/testdata/TestTTFComplex-Regular.ttx rename to Tests/ttLib/data/TestTTFComplex-Regular.ttx diff --git a/Lib/fontTools/ttLib/testdata/test_woff2_metadata.xml b/Tests/ttLib/data/test_woff2_metadata.xml similarity index 100% rename from Lib/fontTools/ttLib/testdata/test_woff2_metadata.xml rename to Tests/ttLib/data/test_woff2_metadata.xml diff --git a/Tests/ttLib/sfnt_test.py b/Tests/ttLib/sfnt_test.py new file mode 100644 index 000000000..2119351d1 --- /dev/null +++ b/Tests/ttLib/sfnt_test.py @@ -0,0 +1,8 @@ +from __future__ import print_function, division, absolute_import +from fontTools.misc.py23 import * +from fontTools.ttLib.sfnt import calcChecksum + + +def test_calcChecksum(): + assert calcChecksum(b"abcd") == 1633837924 + assert calcChecksum(b"abcdxyz") == 3655064932 diff --git a/Lib/fontTools/ttLib/tables/C_F_F_test.py b/Tests/ttLib/tables/C_F_F_test.py similarity index 96% rename from Lib/fontTools/ttLib/tables/C_F_F_test.py rename to Tests/ttLib/tables/C_F_F_test.py index 26781940b..63f767cc0 100644 --- a/Lib/fontTools/ttLib/tables/C_F_F_test.py +++ b/Tests/ttLib/tables/C_F_F_test.py @@ -10,7 +10,7 @@ import unittest CURR_DIR = os.path.abspath(os.path.dirname(os.path.realpath(__file__))) -DATA_DIR = os.path.join(CURR_DIR, 'testdata') +DATA_DIR = os.path.join(CURR_DIR, 'data') CFF_TTX = os.path.join(DATA_DIR, "C_F_F_.ttx") CFF_BIN = os.path.join(DATA_DIR, "C_F_F_.bin") diff --git a/Lib/fontTools/ttLib/tables/C_P_A_L_test.py b/Tests/ttLib/tables/C_P_A_L_test.py similarity index 100% rename from Lib/fontTools/ttLib/tables/C_P_A_L_test.py rename to Tests/ttLib/tables/C_P_A_L_test.py diff --git a/Lib/fontTools/ttLib/tables/M_V_A_R_test.py b/Tests/ttLib/tables/M_V_A_R_test.py similarity index 100% rename from Lib/fontTools/ttLib/tables/M_V_A_R_test.py rename to Tests/ttLib/tables/M_V_A_R_test.py diff --git a/Lib/fontTools/ttLib/tables/O_S_2f_2_test.py b/Tests/ttLib/tables/O_S_2f_2_test.py similarity index 85% rename from Lib/fontTools/ttLib/tables/O_S_2f_2_test.py rename to Tests/ttLib/tables/O_S_2f_2_test.py index 1dc18a108..116e82ea8 100644 --- a/Lib/fontTools/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 @@ -49,6 +49,13 @@ class OS2TableTest(unittest.TestCase): # the bit 122 and the special bit 57 ('Non Plane 0') are also enabled self.assertEqual(os2.recalcUnicodeRanges(font), {0, 7, 9, 57, 122}) + def test_intersectUnicodeRanges(self): + self.assertEqual(intersectUnicodeRanges([0x0410]), {9}) + self.assertEqual(intersectUnicodeRanges([0x0410, 0x1F000]), {9, 57, 122}) + self.assertEqual( + intersectUnicodeRanges([0x0410, 0x1F000], inverse=True), + (set(range(123)) - {9, 57, 122})) + if __name__ == "__main__": import sys diff --git a/Lib/fontTools/ttLib/tables/S_T_A_T_test.py b/Tests/ttLib/tables/S_T_A_T_test.py similarity index 100% rename from Lib/fontTools/ttLib/tables/S_T_A_T_test.py rename to Tests/ttLib/tables/S_T_A_T_test.py diff --git a/Lib/fontTools/ttLib/tables/TupleVariation_test.py b/Tests/ttLib/tables/TupleVariation_test.py similarity index 100% rename from Lib/fontTools/ttLib/tables/TupleVariation_test.py rename to Tests/ttLib/tables/TupleVariation_test.py diff --git a/Lib/fontTools/ttLib/tables/_a_v_a_r_test.py b/Tests/ttLib/tables/_a_v_a_r_test.py similarity index 100% rename from Lib/fontTools/ttLib/tables/_a_v_a_r_test.py rename to Tests/ttLib/tables/_a_v_a_r_test.py diff --git a/Lib/fontTools/ttLib/tables/_c_m_a_p_test.py b/Tests/ttLib/tables/_c_m_a_p_test.py similarity index 96% rename from Lib/fontTools/ttLib/tables/_c_m_a_p_test.py rename to Tests/ttLib/tables/_c_m_a_p_test.py index 1fadcde7a..73ac2395c 100644 --- a/Lib/fontTools/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/Lib/fontTools/ttLib/tables/_c_v_a_r_test.py b/Tests/ttLib/tables/_c_v_a_r_test.py similarity index 100% rename from Lib/fontTools/ttLib/tables/_c_v_a_r_test.py rename to Tests/ttLib/tables/_c_v_a_r_test.py diff --git a/Tests/ttLib/tables/_f_p_g_m_test.py b/Tests/ttLib/tables/_f_p_g_m_test.py new file mode 100644 index 000000000..71fec4816 --- /dev/null +++ b/Tests/ttLib/tables/_f_p_g_m_test.py @@ -0,0 +1,20 @@ +from __future__ import print_function, division, absolute_import, unicode_literals +from fontTools.misc.py23 import * +from fontTools.ttLib.tables._f_p_g_m import table__f_p_g_m +from fontTools.ttLib.tables import ttProgram + + +def test__bool__(): + fpgm = table__f_p_g_m() + assert not bool(fpgm) + + p = ttProgram.Program() + fpgm.program = p + assert not bool(fpgm) + + bc = bytearray([0]) + p.fromBytecode(bc) + assert bool(fpgm) + + p.bytecode.pop() + assert not bool(fpgm) diff --git a/Lib/fontTools/ttLib/tables/_f_v_a_r_test.py b/Tests/ttLib/tables/_f_v_a_r_test.py similarity index 100% rename from Lib/fontTools/ttLib/tables/_f_v_a_r_test.py rename to Tests/ttLib/tables/_f_v_a_r_test.py diff --git a/Tests/ttLib/tables/_g_l_y_f_test.py b/Tests/ttLib/tables/_g_l_y_f_test.py new file mode 100644 index 000000000..0e3005b54 --- /dev/null +++ b/Tests/ttLib/tables/_g_l_y_f_test.py @@ -0,0 +1,137 @@ +from __future__ import print_function, division, absolute_import +from fontTools.misc.py23 import * +from fontTools.ttLib.tables._g_l_y_f import GlyphCoordinates +import sys +import pytest + + +class GlyphCoordinatesTest(object): + + def test_translate(self): + g = GlyphCoordinates([(1,2)]) + g.translate((.5,0)) + assert g == GlyphCoordinates([(1.5,2.0)]) + + def test_scale(self): + g = GlyphCoordinates([(1,2)]) + g.scale((.5,0)) + assert g == GlyphCoordinates([(0.5,0.0)]) + + def test_transform(self): + g = GlyphCoordinates([(1,2)]) + g.transform(((.5,0),(.2,.5))) + assert g[0] == GlyphCoordinates([(0.9,1.0)])[0] + + def test__eq__(self): + g = GlyphCoordinates([(1,2)]) + g2 = GlyphCoordinates([(1.0,2)]) + g3 = GlyphCoordinates([(1.5,2)]) + assert g == g2 + assert not g == g3 + assert not g2 == g3 + assert not g == object() + + def test__ne__(self): + g = GlyphCoordinates([(1,2)]) + g2 = GlyphCoordinates([(1.0,2)]) + g3 = GlyphCoordinates([(1.5,2)]) + assert not (g != g2) + assert g != g3 + assert g2 != g3 + assert g != object() + + def test__pos__(self): + g = GlyphCoordinates([(1,2)]) + g2 = +g + assert g == g2 + + def test__neg__(self): + g = GlyphCoordinates([(1,2)]) + g2 = -g + assert g2 == GlyphCoordinates([(-1, -2)]) + + def test__abs__(self): + g = GlyphCoordinates([(-1.5,2)]) + g2 = abs(g) + assert g2 == GlyphCoordinates([(1.5,2)]) + + @pytest.mark.skipif(sys.version_info[0] < 3, + reason="__round___ requires Python 3") + def test__round__(self): + g = GlyphCoordinates([(-1.5,2)]) + g2 = round(g) + assert g2 == GlyphCoordinates([(-2,2)]) + + def test__add__(self): + g1 = GlyphCoordinates([(1,2)]) + g2 = GlyphCoordinates([(3,4)]) + g3 = GlyphCoordinates([(4,6)]) + assert g1 + g2 == g3 + assert g1 + (1, 1) == GlyphCoordinates([(2,3)]) + with pytest.raises(TypeError) as excinfo: + assert g1 + object() + assert 'unsupported operand' in str(excinfo.value) + + def test__sub__(self): + g1 = GlyphCoordinates([(1,2)]) + g2 = GlyphCoordinates([(3,4)]) + g3 = GlyphCoordinates([(-2,-2)]) + assert g1 - g2 == g3 + assert g1 - (1, 1) == GlyphCoordinates([(0,1)]) + with pytest.raises(TypeError) as excinfo: + assert g1 - object() + assert 'unsupported operand' in str(excinfo.value) + + def test__rsub__(self): + g = GlyphCoordinates([(1,2)]) + # other + (-self) + assert (1, 1) - g == GlyphCoordinates([(0,-1)]) + + def test__mul__(self): + g = GlyphCoordinates([(1,2)]) + assert g * 3 == GlyphCoordinates([(3,6)]) + assert g * (3,2) == GlyphCoordinates([(3,4)]) + assert g * (1,1) == g + with pytest.raises(TypeError) as excinfo: + assert g * object() + assert 'unsupported operand' in str(excinfo.value) + + def test__truediv__(self): + g = GlyphCoordinates([(1,2)]) + assert g / 2 == GlyphCoordinates([(.5,1)]) + assert g / (1, 2) == GlyphCoordinates([(1,1)]) + assert g / (1, 1) == g + with pytest.raises(TypeError) as excinfo: + assert g / object() + assert 'unsupported operand' in str(excinfo.value) + + def test__iadd__(self): + g = GlyphCoordinates([(1,2)]) + g += (.5,0) + assert g == GlyphCoordinates([(1.5, 2.0)]) + g2 = GlyphCoordinates([(3,4)]) + g += g2 + assert g == GlyphCoordinates([(4.5, 6.0)]) + + def test__isub__(self): + g = GlyphCoordinates([(1,2)]) + g -= (.5, 0) + assert g == GlyphCoordinates([(0.5, 2.0)]) + g2 = GlyphCoordinates([(3,4)]) + g -= g2 + assert g == GlyphCoordinates([(-2.5, -2.0)]) + + def __test__imul__(self): + g = GlyphCoordinates([(1,2)]) + g *= (2,.5) + g *= 2 + assert g == GlyphCoordinates([(4.0, 2.0)]) + g = GlyphCoordinates([(1,2)]) + g *= 2 + assert g == GlyphCoordinates([(2, 4)]) + + def test__itruediv__(self): + g = GlyphCoordinates([(1,3)]) + g /= (.5,1.5) + g /= 2 + assert g == GlyphCoordinates([(1.0, 1.0)]) diff --git a/Lib/fontTools/ttLib/tables/_g_v_a_r_test.py b/Tests/ttLib/tables/_g_v_a_r_test.py similarity index 100% rename from Lib/fontTools/ttLib/tables/_g_v_a_r_test.py rename to Tests/ttLib/tables/_g_v_a_r_test.py diff --git a/Lib/fontTools/ttLib/tables/_h_h_e_a_test.py b/Tests/ttLib/tables/_h_h_e_a_test.py similarity index 100% rename from Lib/fontTools/ttLib/tables/_h_h_e_a_test.py rename to Tests/ttLib/tables/_h_h_e_a_test.py diff --git a/Lib/fontTools/ttLib/tables/_h_m_t_x_test.py b/Tests/ttLib/tables/_h_m_t_x_test.py similarity index 100% rename from Lib/fontTools/ttLib/tables/_h_m_t_x_test.py rename to Tests/ttLib/tables/_h_m_t_x_test.py diff --git a/Lib/fontTools/ttLib/tables/_k_e_r_n_test.py b/Tests/ttLib/tables/_k_e_r_n_test.py similarity index 94% rename from Lib/fontTools/ttLib/tables/_k_e_r_n_test.py rename to Tests/ttLib/tables/_k_e_r_n_test.py index 932047439..1dacb936e 100644 --- a/Lib/fontTools/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/Lib/fontTools/ttLib/tables/_l_t_a_g_test.py b/Tests/ttLib/tables/_l_t_a_g_test.py similarity index 96% rename from Lib/fontTools/ttLib/tables/_l_t_a_g_test.py rename to Tests/ttLib/tables/_l_t_a_g_test.py index a24c3460a..78a05edb2 100644 --- a/Lib/fontTools/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/Lib/fontTools/ttLib/tables/_m_e_t_a_test.py b/Tests/ttLib/tables/_m_e_t_a_test.py similarity index 100% rename from Lib/fontTools/ttLib/tables/_m_e_t_a_test.py rename to Tests/ttLib/tables/_m_e_t_a_test.py diff --git a/Lib/fontTools/ttLib/tables/_n_a_m_e_test.py b/Tests/ttLib/tables/_n_a_m_e_test.py similarity index 98% rename from Lib/fontTools/ttLib/tables/_n_a_m_e_test.py rename to Tests/ttLib/tables/_n_a_m_e_test.py index 9656fa524..30f1044f8 100644 --- a/Lib/fontTools/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/Lib/fontTools/ttLib/tables/_t_r_a_k_test.py b/Tests/ttLib/tables/_t_r_a_k_test.py similarity index 100% rename from Lib/fontTools/ttLib/tables/_t_r_a_k_test.py rename to Tests/ttLib/tables/_t_r_a_k_test.py diff --git a/Lib/fontTools/ttLib/tables/_v_h_e_a_test.py b/Tests/ttLib/tables/_v_h_e_a_test.py similarity index 100% rename from Lib/fontTools/ttLib/tables/_v_h_e_a_test.py rename to Tests/ttLib/tables/_v_h_e_a_test.py diff --git a/Lib/fontTools/ttLib/tables/_v_m_t_x_test.py b/Tests/ttLib/tables/_v_m_t_x_test.py similarity index 90% rename from Lib/fontTools/ttLib/tables/_v_m_t_x_test.py rename to Tests/ttLib/tables/_v_m_t_x_test.py index 4c9f08c7a..f55dbeca9 100644 --- a/Lib/fontTools/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/Lib/fontTools/ttLib/tables/testdata/C_F_F_.bin b/Tests/ttLib/tables/data/C_F_F_.bin similarity index 100% rename from Lib/fontTools/ttLib/tables/testdata/C_F_F_.bin rename to Tests/ttLib/tables/data/C_F_F_.bin diff --git a/Lib/fontTools/ttLib/tables/testdata/C_F_F_.ttx b/Tests/ttLib/tables/data/C_F_F_.ttx similarity index 100% rename from Lib/fontTools/ttLib/tables/testdata/C_F_F_.ttx rename to Tests/ttLib/tables/data/C_F_F_.ttx diff --git a/Lib/fontTools/ttLib/tables/otBase_test.py b/Tests/ttLib/tables/otBase_test.py similarity index 100% rename from Lib/fontTools/ttLib/tables/otBase_test.py rename to Tests/ttLib/tables/otBase_test.py diff --git a/Lib/fontTools/ttLib/tables/otConverters_test.py b/Tests/ttLib/tables/otConverters_test.py similarity index 100% rename from Lib/fontTools/ttLib/tables/otConverters_test.py rename to Tests/ttLib/tables/otConverters_test.py diff --git a/Lib/fontTools/ttLib/tables/otTables_test.py b/Tests/ttLib/tables/otTables_test.py similarity index 100% rename from Lib/fontTools/ttLib/tables/otTables_test.py rename to Tests/ttLib/tables/otTables_test.py diff --git a/Tests/ttLib/tables/ttProgram_test.py b/Tests/ttLib/tables/ttProgram_test.py new file mode 100644 index 000000000..d5b995df8 --- /dev/null +++ b/Tests/ttLib/tables/ttProgram_test.py @@ -0,0 +1,87 @@ +from __future__ import print_function, division, absolute_import +from fontTools.misc.py23 import * +from fontTools.ttLib.tables.ttProgram import Program +from fontTools.misc.textTools import deHexStr +import array + + +BYTECODE = deHexStr( + '403b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a' + '191817161514131211100f0e0d0c0b0a090807060504030201002c01b0184358456ab0' + '194360b0462344231020b0464ef04d2fb000121b21231133592d2c01b0184358b0052b' + 'b000134bb0145058b100403859b0062b1b21231133592d2c01b01843584eb0032510f2' + '21b000124d1b2045b00425b00425234a6164b0285258212310d61bb0032510f221b000' + '1259592d2cb01a435821211bb00225b0022549b00325b003254a612064b01050582121' + '211bb00325b0032549b0005058b0005058b8ffe238211bb0103821591bb0005258b01e' + '38211bb8fff03821595959592d2c01b0184358b0052bb000134bb0145058b90000ffc0' + '3859b0062b1b21231133592d2c4e018a10b146194344b00014b10046e2b00015b90000' + 'fff03800b0003cb0282bb0022510b0003c2d2c0118b0002fb00114f2b00113b001154d' + 'b000122d2c01b0184358b0052bb00013b90000ffe038b0062b1b21231133592d2c01b0' + '18435845646a23456469b01943646060b0462344231020b046f02fb000121b2121208a' + '208a525811331b212159592d2c01b10b0a432343650a2d2c00b10a0b4323430b2d2c00' + 'b0462370b101463e01b0462370b10246453ab10200080d2d2cb0122bb0022545b00225' + '456ab0408b60b0022523442121212d2cb0132bb0022545b00225456ab8ffc08c60b002' + '2523442121212d2cb000b0122b2121212d2cb000b0132b2121212d2c01b00643b00743' + '650a2d2c2069b04061b0008b20b12cc08a8cb8100062602b0c642364615c58b0036159' + '2d2cb1000325456854b01c4b505a58b0032545b0032545606820b004252344b0042523' + '441bb00325204568208a2344b00325456860b003252344592d2cb00325204568208a23' + '44b003254564686560b00425b0016023442d2cb00943588721c01bb01243588745b011' + '2bb0472344b0477ae41b038a45186920b04723448a8a8720b0a05158b0112bb0472344' + 'b0477ae41b21b0477ae4595959182d2c208a4523456860442d2c456a422d2c01182f2d' + '2c01b0184358b00425b00425496423456469b0408b6120b080626ab00225b00225618c' + 'b0194360b0462344218a10b046f6211b21212121592d2c01b0184358b0022545b00225' + '4564606ab00325456a6120b00425456a208a8b65b0042523448cb00325234421211b20' + '456a4420456a44592d2c012045b00055b018435a584568234569b0408b6120b080626a' + '208a236120b003258b65b0042523448cb00325234421211b2121b0192b592d2c018a8a' + '45642345646164422d2cb00425b00425b0192bb0184358b00425b00425b00325b01b2b' + '01b0022543b04054b0022543b000545a58b003252045b040614459b0022543b00054b0' + '022543b040545a58b004252045b04060445959212121212d2c014b525843b002254523' + '61441b2121592d2c014b525843b00225452360441b2121592d2c4b525845441b212159' + '2d2c0120b003252349b04060b0206320b000525823b002253823b002256538008a6338' + '1b212121212159012d2c4b505845441b2121592d2c01b005251023208af500b0016023' + 'edec2d2c01b005251023208af500b0016123edec2d2c01b0062510f500edec2d2c4623' + '46608a8a462320468a608a61b8ff8062232010238ab14b4b8a70456020b0005058b001' + '61b8ffba8b1bb0468c59b0106068013a2d2c2045b00325465258b0022546206861b003' + '25b003253f2321381b2111592d2c2045b00325465058b0022546206861b00325b00325' + '3f2321381b2111592d2c00b00743b006430b2d2c8a10ec2d2cb00c4358211b2046b000' + '5258b8fff0381bb0103859592d2c20b0005558b8100063b003254564b00325456461b0' + '005358b0021bb04061b00359254569535845441b2121591b21b0022545b00225456164' + 'b028515845441b212159592d2c21210c6423648bb84000622d2c21b08051580c642364' + '8bb82000621bb200402f2b59b002602d2c21b0c051580c6423648bb81555621bb20080' + '2f2b59b002602d2c0c6423648bb84000626023212d2c4b5358b00425b0042549642345' + '6469b0408b6120b080626ab00225b00225618cb0462344218a10b046f6211b218a1123' + '1220392f592d2cb00225b002254964b0c05458b8fff838b008381b2121592d2cb01343' + '58031b02592d2cb0134358021b03592d2cb00a2b2310203cb0172b2d2cb00225b8fff0' + '38b0282b8a102320d023b0102bb0054358c01b3c59201011b00012012d2c4b53234b51' + '5a58381b2121592d2c01b0022510d023c901b00113b0001410b0013cb001162d2c01b0' + '0013b001b0032549b0031738b001132d2c4b53234b515a5820458a60441b2121592d2c' + '20392f2d') + + +class ProgramTest(object): + + def test__bool__(self): + p = Program() + assert not bool(p) + + bc = array.array("B", [0]) + p.fromBytecode(bc) + assert bool(p) + + assert p.bytecode.pop() == 0 + assert not bool(p) + + p = Program() + asm = ['SVTCA[0]'] + p.fromAssembly(asm) + assert bool(p) + + assert p.assembly.pop() == 'SVTCA[0]' + assert not bool(p) + + def test_roundtrip(self): + p = Program() + p.fromBytecode(BYTECODE) + asm = p.getAssembly(preserve=True) + p.fromAssembly(asm) + assert BYTECODE == p.getBytecode() diff --git a/Lib/fontTools/ttLib/woff2_test.py b/Tests/ttLib/woff2_test.py similarity index 90% rename from Lib/fontTools/ttLib/woff2_test.py rename to Tests/ttLib/woff2_test.py index 4ecc970c9..036e10e15 100644 --- a/Lib/fontTools/ttLib/woff2_test.py +++ b/Tests/ttLib/woff2_test.py @@ -1,13 +1,15 @@ 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, - WOFF2Writer) + WOFF2Writer, unpackBase128, unpack255UShort, pack255UShort) import unittest from fontTools.misc import sstruct +import struct import os import random import copy @@ -28,7 +30,7 @@ if not hasattr(unittest.TestCase, 'assertRaisesRegex'): current_dir = os.path.abspath(os.path.dirname(os.path.realpath(__file__))) -data_dir = os.path.join(current_dir, 'testdata') +data_dir = os.path.join(current_dir, 'data') TTX = os.path.join(data_dir, 'TestTTF-Regular.ttx') OTX = os.path.join(data_dir, 'TestOTF-Regular.otx') METADATA = os.path.join(data_dir, 'test_woff2_metadata.xml') @@ -745,6 +747,94 @@ class WOFF2GlyfTableTest(unittest.TestCase): self.assertEqual(normGlyfData, reconstructedData) +class Base128Test(unittest.TestCase): + + def test_unpackBase128(self): + self.assertEqual(unpackBase128(b'\x3f\x00\x00'), (63, b"\x00\x00")) + self.assertEqual(unpackBase128(b'\x8f\xff\xff\xff\x7f')[0], 4294967295) + + self.assertRaisesRegex( + ttLib.TTLibError, + "UIntBase128 value must not start with leading zeros", + unpackBase128, b'\x80\x80\x3f') + + self.assertRaisesRegex( + ttLib.TTLibError, + "UIntBase128-encoded sequence is longer than 5 bytes", + unpackBase128, b'\x8f\xff\xff\xff\xff\x7f') + + self.assertRaisesRegex( + ttLib.TTLibError, + "UIntBase128 value exceeds 2\*\*32-1", + unpackBase128, b'\x90\x80\x80\x80\x00') + + self.assertRaisesRegex( + ttLib.TTLibError, + "not enough data to unpack UIntBase128", + unpackBase128, b'') + + def test_base128Size(self): + self.assertEqual(base128Size(0), 1) + self.assertEqual(base128Size(24567), 3) + self.assertEqual(base128Size(2**32-1), 5) + + def test_packBase128(self): + self.assertEqual(packBase128(63), b"\x3f") + self.assertEqual(packBase128(2**32-1), b'\x8f\xff\xff\xff\x7f') + self.assertRaisesRegex( + ttLib.TTLibError, + "UIntBase128 format requires 0 <= integer <= 2\*\*32-1", + packBase128, 2**32+1) + self.assertRaisesRegex( + ttLib.TTLibError, + "UIntBase128 format requires 0 <= integer <= 2\*\*32-1", + packBase128, -1) + + +class UShort255Test(unittest.TestCase): + + def test_unpack255UShort(self): + self.assertEqual(unpack255UShort(bytechr(252))[0], 252) + # some numbers (e.g. 506) can have multiple encodings + self.assertEqual( + unpack255UShort(struct.pack("BB", 254, 0))[0], 506) + self.assertEqual( + unpack255UShort(struct.pack("BB", 255, 253))[0], 506) + self.assertEqual( + unpack255UShort(struct.pack("BBB", 253, 1, 250))[0], 506) + + self.assertRaisesRegex( + ttLib.TTLibError, + "not enough data to unpack 255UInt16", + unpack255UShort, struct.pack("BB", 253, 0)) + + self.assertRaisesRegex( + ttLib.TTLibError, + "not enough data to unpack 255UInt16", + unpack255UShort, struct.pack("B", 254)) + + self.assertRaisesRegex( + ttLib.TTLibError, + "not enough data to unpack 255UInt16", + unpack255UShort, struct.pack("B", 255)) + + def test_pack255UShort(self): + self.assertEqual(pack255UShort(252), b'\xfc') + self.assertEqual(pack255UShort(505), b'\xff\xfc') + self.assertEqual(pack255UShort(506), b'\xfe\x00') + self.assertEqual(pack255UShort(762), b'\xfd\x02\xfa') + + self.assertRaisesRegex( + ttLib.TTLibError, + "255UInt16 format requires 0 <= integer <= 65535", + pack255UShort, -1) + + self.assertRaisesRegex( + ttLib.TTLibError, + "255UInt16 format requires 0 <= integer <= 65535", + pack255UShort, 0xFFFF+1) + + if __name__ == "__main__": import sys sys.exit(unittest.main()) diff --git a/Lib/fontTools/varLib/testdata/VarLibTest.designspace b/Tests/varLib/data/VarLibTest.designspace similarity index 100% rename from Lib/fontTools/varLib/testdata/VarLibTest.designspace rename to Tests/varLib/data/VarLibTest.designspace diff --git a/Lib/fontTools/varLib/designspace_test.py b/Tests/varLib/designspace_test.py similarity index 95% rename from Lib/fontTools/varLib/designspace_test.py rename to Tests/varLib/designspace_test.py index 7e51693ae..54136309f 100644 --- a/Lib/fontTools/varLib/designspace_test.py +++ b/Tests/varLib/designspace_test.py @@ -29,7 +29,7 @@ class DesignspaceTest(unittest.TestCase): def _getpath(testfile): path, _ = os.path.split(__file__) - return os.path.join(path, "testdata", testfile) + return os.path.join(path, "data", testfile) if __name__ == "__main__": diff --git a/Tests/varLib/models_test.py b/Tests/varLib/models_test.py new file mode 100644 index 000000000..c0d2000b4 --- /dev/null +++ b/Tests/varLib/models_test.py @@ -0,0 +1,77 @@ +from __future__ import print_function, division, absolute_import +from fontTools.misc.py23 import * +from fontTools.varLib.models import ( + normalizeLocation, supportScalar, VariationModel) + + +def test_normalizeLocation(): + axes = {"wght": (100, 400, 900)} + assert normalizeLocation({"wght": 400}, axes) == {'wght': 0} + assert normalizeLocation({"wght": 100}, axes) == {'wght': -1.0} + assert normalizeLocation({"wght": 900}, axes) == {'wght': 1.0} + assert normalizeLocation({"wght": 650}, axes) == {'wght': 0.5} + assert normalizeLocation({"wght": 1000}, axes) == {'wght': 1.0} + assert normalizeLocation({"wght": 0}, axes) == {'wght': -1.0} + + axes = {"wght": (0, 0, 1000)} + assert normalizeLocation({"wght": 0}, axes) == {'wght': 0} + assert normalizeLocation({"wght": -1}, axes) == {'wght': 0} + assert normalizeLocation({"wght": 1000}, axes) == {'wght': 1.0} + assert normalizeLocation({"wght": 500}, axes) == {'wght': 0.5} + assert normalizeLocation({"wght": 1001}, axes) == {'wght': 1.0} + + axes = {"wght": (0, 1000, 1000)} + assert normalizeLocation({"wght": 0}, axes) == {'wght': -1.0} + assert normalizeLocation({"wght": -1}, axes) == {'wght': -1.0} + assert normalizeLocation({"wght": 500}, axes) == {'wght': -0.5} + assert normalizeLocation({"wght": 1000}, axes) == {'wght': 0} + assert normalizeLocation({"wght": 1001}, axes) == {'wght': 0} + + +def test_supportScalar(): + assert supportScalar({}, {}) == 1.0 + assert supportScalar({'wght':.2}, {}) == 1.0 + assert supportScalar({'wght':.2}, {'wght':(0,2,3)}) == 0.1 + assert supportScalar({'wght':2.5}, {'wght':(0,2,4)}) == 0.75 + + +def test_VariationModel(): + locations = [ + {'wght':100}, + {'wght':-100}, + {'wght':-180}, + {'wdth':+.3}, + {'wght':+120,'wdth':.3}, + {'wght':+120,'wdth':.2}, + {}, + {'wght':+180,'wdth':.3}, + {'wght':+180}, + ] + model = VariationModel(locations, axisOrder=['wght']) + + assert model.locations == [ + {}, + {'wght': -100}, + {'wght': -180}, + {'wght': 100}, + {'wght': 180}, + {'wdth': 0.3}, + {'wdth': 0.3, 'wght': 180}, + {'wdth': 0.3, 'wght': 120}, + {'wdth': 0.2, 'wght': 120}] + + assert model.deltaWeights == [ + {}, + {0: 1.0}, + {0: 1.0}, + {0: 1.0}, + {0: 1.0}, + {0: 1.0}, + {0: 1.0, 4: 1.0, 5: 1.0}, + {0: 1.0, 3: 0.75, 4: 0.25, 5: 1.0, 6: 0.25}, + {0: 1.0, + 3: 0.75, + 4: 0.25, + 5: 0.6666666666666667, + 6: 0.16666666666666669, + 7: 0.6666666666666667}] diff --git a/Lib/fontTools/voltLib/lexer_test.py b/Tests/voltLib/lexer_test.py similarity index 100% rename from Lib/fontTools/voltLib/lexer_test.py rename to Tests/voltLib/lexer_test.py diff --git a/Lib/fontTools/voltLib/parser_test.py b/Tests/voltLib/parser_test.py similarity index 100% rename from Lib/fontTools/voltLib/parser_test.py rename to Tests/voltLib/parser_test.py diff --git a/dev-requirements.txt b/dev-requirements.txt index 0788bd281..fb728e261 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,3 @@ -pytest>=2.8 -virtualenv>=15.0 -tox>=2.3 - -# We use a fork of bumpversion due to missing support for annotated tags. -# See peritus/bumpversion#58 -git+https://github.com/anthrotype/bumpversion.git@annotated-tags#egg=bumpversion +pytest>=3.0 +tox>=2.5 +bumpversion>=0.5.3 diff --git a/setup.cfg b/setup.cfg index 73ec36561..ab286c59c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,9 +37,9 @@ test = pytest license_file = LICENSE [tool:pytest] -minversion = 2.8 +minversion = 3.0 testpaths = - Lib/fontTools + Tests python_files = *_test.py python_classes = diff --git a/setup.py b/setup.py index c3a2a7f65..a219ea8ba 100755 --- a/setup.py +++ b/setup.py @@ -324,7 +324,7 @@ setup( data_files=find_data_files(), setup_requires=pytest_runner + wheel + bumpversion, tests_require=[ - 'pytest>=2.8', + 'pytest>=3.0', ], entry_points={ 'console_scripts': [ diff --git a/tox.ini b/tox.ini index 1302c4963..50130ca0e 100644 --- a/tox.ini +++ b/tox.ini @@ -19,8 +19,8 @@ commands = # We use parallel mode and then combine later so that coverage.py will take # paths like .tox/py36/lib/python3.6/site-packages/fontTools and collapse # them into Lib/fontTools. - cov: coverage run --parallel-mode -m pytest {posargs:--pyargs fontTools} - nocov: pytest {posargs:--pyargs fontTools} + cov: coverage run --parallel-mode -m pytest {posargs} + nocov: pytest {posargs} [testenv:htmlcov] basepython = {env:TOXPYTHON:python3.5} @@ -29,7 +29,7 @@ deps = skip_install = true commands = coverage combine - coverage html + coverage html {posargs} [testenv:codecov] passenv = *