[varLib.avar] Add roundtrip test
Fails currently.
This commit is contained in:
parent
132654c9e5
commit
8d58f7f730
@ -1,11 +1,9 @@
|
|||||||
|
from fontTools.varLib.models import VariationModel
|
||||||
from fontTools.varLib.avar import _pruneLocations
|
from fontTools.varLib.avar import _pruneLocations
|
||||||
import unittest
|
import unittest
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
TESTS = [
|
||||||
@pytest.mark.parametrize(
|
|
||||||
"locations, poles, expected",
|
|
||||||
[
|
|
||||||
(
|
(
|
||||||
[
|
[
|
||||||
{"wght": 1},
|
{"wght": 1},
|
||||||
@ -44,8 +42,10 @@ import pytest
|
|||||||
{"wght": 0.5, "wdth": 0.5},
|
{"wght": 0.5, "wdth": 0.5},
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
]
|
||||||
)
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("locations, poles, expected", TESTS)
|
||||||
def test_pruneLocations(locations, poles, expected):
|
def test_pruneLocations(locations, poles, expected):
|
||||||
axisTags = set()
|
axisTags = set()
|
||||||
for location in locations:
|
for location in locations:
|
||||||
@ -54,6 +54,29 @@ def test_pruneLocations(locations, poles, expected):
|
|||||||
|
|
||||||
locations = [{}] + locations
|
locations = [{}] + locations
|
||||||
|
|
||||||
output = _pruneLocations(locations, poles, axisTags)
|
pruned = _pruneLocations(locations, poles, axisTags)
|
||||||
|
|
||||||
assert output == expected, (output, expected)
|
assert pruned == expected, (pruned, expected)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("locations, poles, expected", TESTS)
|
||||||
|
def test_roundtrip(locations, poles, expected):
|
||||||
|
axisTags = set()
|
||||||
|
for location in locations:
|
||||||
|
axisTags.update(location.keys())
|
||||||
|
axisTags = sorted(axisTags)
|
||||||
|
|
||||||
|
locations = [{}] + locations
|
||||||
|
expected = [{}] + expected
|
||||||
|
|
||||||
|
model1 = VariationModel(locations, axisTags)
|
||||||
|
model2 = VariationModel(expected, axisTags)
|
||||||
|
|
||||||
|
for location in poles:
|
||||||
|
i = model1.locations.index(location)
|
||||||
|
support1 = model1.supports[i]
|
||||||
|
|
||||||
|
i = model2.locations.index(location)
|
||||||
|
support2 = model2.supports[i]
|
||||||
|
|
||||||
|
assert support1 == support2, (support1, support2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user