models_test: parametrize VariationModel tests
I noticed there were two functions called 'test_VariationModel', the second one shadowing the first.
This commit is contained in:
parent
389cf7c56a
commit
7e85782900
@ -2,6 +2,7 @@ from __future__ import print_function, division, absolute_import
|
||||
from fontTools.misc.py23 import *
|
||||
from fontTools.varLib.models import (
|
||||
normalizeLocation, supportScalar, VariationModel)
|
||||
import pytest
|
||||
|
||||
|
||||
def test_normalizeLocation():
|
||||
@ -35,8 +36,11 @@ def test_supportScalar():
|
||||
assert supportScalar({'wght':2.5}, {'wght':(0,2,4)}) == 0.75
|
||||
|
||||
|
||||
def test_VariationModel():
|
||||
locations = [
|
||||
@pytest.mark.parametrize(
|
||||
"locations, axisOrder, sortedLocs, supports, deltaWeights",
|
||||
[
|
||||
(
|
||||
[
|
||||
{'wght':100},
|
||||
{'wght':-100},
|
||||
{'wght':-180},
|
||||
@ -46,10 +50,9 @@ def test_VariationModel():
|
||||
{},
|
||||
{'wght':+180,'wdth':.3},
|
||||
{'wght':+180},
|
||||
]
|
||||
model = VariationModel(locations, axisOrder=['wght'])
|
||||
|
||||
assert model.locations == [
|
||||
],
|
||||
["wght"],
|
||||
[
|
||||
{},
|
||||
{'wght': -100},
|
||||
{'wght': -180},
|
||||
@ -58,9 +61,20 @@ def test_VariationModel():
|
||||
{'wdth': 0.3},
|
||||
{'wdth': 0.3, 'wght': 180},
|
||||
{'wdth': 0.3, 'wght': 120},
|
||||
{'wdth': 0.2, 'wght': 120}]
|
||||
|
||||
assert model.deltaWeights == [
|
||||
{'wdth': 0.2, 'wght': 120}
|
||||
],
|
||||
[
|
||||
{},
|
||||
{'wght': (-180, -100, 0)},
|
||||
{'wght': (-180, -180, -100)},
|
||||
{'wght': (0, 100, 180)},
|
||||
{'wght': (100, 180, 180)},
|
||||
{'wdth': (0, 0.3, 0.3)},
|
||||
{'wdth': (0, 0.3, 0.3), 'wght': (0, 180, 180)},
|
||||
{'wdth': (0, 0.3, 0.3), 'wght': (0, 120, 180)},
|
||||
{'wdth': (0, 0.2, 0.3), 'wght': (0, 120, 180)}
|
||||
],
|
||||
[
|
||||
{},
|
||||
{0: 1.0},
|
||||
{0: 1.0},
|
||||
@ -74,26 +88,51 @@ def test_VariationModel():
|
||||
4: 0.25,
|
||||
5: 0.6666666666666667,
|
||||
6: 0.4444444444444445,
|
||||
7: 0.6666666666666667}]
|
||||
|
||||
def test_VariationModel():
|
||||
locations = [
|
||||
7: 0.6666666666666667}
|
||||
]
|
||||
),
|
||||
(
|
||||
[
|
||||
{},
|
||||
{'bar': 0.5},
|
||||
{'bar': 1.0},
|
||||
{'foo': 1.0},
|
||||
{'bar': 0.5, 'foo': 1.0},
|
||||
{'bar': 1.0, 'foo': 1.0},
|
||||
]
|
||||
model = VariationModel(locations)
|
||||
|
||||
assert model.locations == locations
|
||||
|
||||
assert model.supports == [
|
||||
],
|
||||
None,
|
||||
[
|
||||
{},
|
||||
{'bar': 0.5},
|
||||
{'bar': 1.0},
|
||||
{'foo': 1.0},
|
||||
{'bar': 0.5, 'foo': 1.0},
|
||||
{'bar': 1.0, 'foo': 1.0},
|
||||
],
|
||||
[
|
||||
{},
|
||||
{'bar': (0, 0.5, 1.0)},
|
||||
{'bar': (0.5, 1.0, 1.0)},
|
||||
{'foo': (0, 1.0, 1.0)},
|
||||
{'bar': (0, 0.5, 1.0), 'foo': (0, 1.0, 1.0)},
|
||||
{'bar': (0.5, 1.0, 1.0), 'foo': (0, 1.0, 1.0)},
|
||||
],
|
||||
[
|
||||
{},
|
||||
{0: 1.0},
|
||||
{0: 1.0},
|
||||
{0: 1.0},
|
||||
{0: 1.0, 1: 1.0, 3: 1.0},
|
||||
{0: 1.0, 2: 1.0, 3: 1.0},
|
||||
],
|
||||
)
|
||||
]
|
||||
)
|
||||
def test_VariationModel(
|
||||
locations, axisOrder, sortedLocs, supports, deltaWeights
|
||||
):
|
||||
model = VariationModel(locations, axisOrder=axisOrder)
|
||||
|
||||
assert model.locations == sortedLocs
|
||||
assert model.supports == supports
|
||||
assert model.deltaWeights == deltaWeights
|
||||
|
Loading…
x
Reference in New Issue
Block a user