Fix up tests

This commit is contained in:
Nikolaus Waxweiler 2022-04-29 18:13:03 +01:00
parent 177e0a71b8
commit 9f984d93f7
3 changed files with 40 additions and 24 deletions

View File

@ -34,7 +34,7 @@ def test_read_v5_document_simple(datadir):
[ [
AxisDescriptor( AxisDescriptor(
tag="wght", tag="wght",
name="weight", name="Weight",
minimum=200, minimum=200,
maximum=1000, maximum=1000,
default=200, default=200,
@ -82,7 +82,7 @@ def test_read_v5_document_simple(datadir):
), ),
AxisDescriptor( AxisDescriptor(
tag="wdth", tag="wdth",
name="width", name="Width",
minimum=50, minimum=50,
maximum=150, maximum=150,
default=100, default=100,
@ -123,10 +123,10 @@ def test_read_v5_document_simple(datadir):
LocationLabelDescriptor( LocationLabelDescriptor(
name="Some Style", name="Some Style",
labelNames={"fr": "Un Style"}, labelNames={"fr": "Un Style"},
userLocation={"weight": 300, "width": 50, "Italic": 0}, userLocation={"Weight": 300, "Width": 50, "Italic": 0},
), ),
LocationLabelDescriptor( LocationLabelDescriptor(
name="Other", userLocation={"weight": 700, "width": 100, "Italic": 1} name="Other", userLocation={"Weight": 700, "Width": 100, "Italic": 1}
), ),
], ],
) )
@ -139,7 +139,7 @@ def test_read_v5_document_simple(datadir):
path=posix(str((datadir / "masters/masterTest1.ufo").resolve())), path=posix(str((datadir / "masters/masterTest1.ufo").resolve())),
name="master.ufo1", name="master.ufo1",
layerName=None, layerName=None,
location={"weight": 0.0, "width": 20.0}, location={"Italic": 0.0, "Weight": 0.0, "Width": 20.0},
copyLib=True, copyLib=True,
copyInfo=True, copyInfo=True,
copyGroups=False, copyGroups=False,
@ -156,7 +156,7 @@ def test_read_v5_document_simple(datadir):
path=posix(str((datadir / "masters/masterTest2.ufo").resolve())), path=posix(str((datadir / "masters/masterTest2.ufo").resolve())),
name="master.ufo2", name="master.ufo2",
layerName=None, layerName=None,
location={"weight": 1000.0, "width": 20.0}, location={"Italic": 0.0, "Weight": 1000.0, "Width": 20.0},
copyLib=False, copyLib=False,
copyInfo=False, copyInfo=False,
copyGroups=False, copyGroups=False,
@ -173,7 +173,7 @@ def test_read_v5_document_simple(datadir):
path=posix(str((datadir / "masters/masterTest2.ufo").resolve())), path=posix(str((datadir / "masters/masterTest2.ufo").resolve())),
name="master.ufo2", name="master.ufo2",
layerName="supports", layerName="supports",
location={"weight": 1000.0, "width": 20.0}, location={"Italic": 0.0, "Weight": 1000.0, "Width": 20.0},
copyLib=False, copyLib=False,
copyInfo=False, copyInfo=False,
copyGroups=False, copyGroups=False,
@ -185,6 +185,22 @@ def test_read_v5_document_simple(datadir):
styleName="Supports", styleName="Supports",
localisedFamilyName={}, localisedFamilyName={},
), ),
SourceDescriptor(
filename="masters/masterTest2.ufo",
path=posix(str((datadir / "masters/masterTest2.ufo").resolve())),
name="master.ufo3",
layerName=None,
location={"Italic": 1.0, "Weight": 0.0, "Width": 100.0},
copyLib=False,
copyGroups=False,
copyFeatures=False,
muteKerning=False,
muteInfo=False,
mutedGlyphNames=[],
familyName="MasterFamilyName",
styleName="FauxItalic",
localisedFamilyName={},
),
], ],
) )
@ -245,7 +261,7 @@ def test_read_v5_document_simple(datadir):
filename="instances/instanceTest1.ufo", filename="instances/instanceTest1.ufo",
path=posix(str((datadir / "instances/instanceTest1.ufo").resolve())), path=posix(str((datadir / "instances/instanceTest1.ufo").resolve())),
name="instance.ufo1", name="instance.ufo1",
designLocation={"weight": 500.0, "width": 20.0}, designLocation={"Weight": 500.0, "Width": 20.0},
familyName="InstanceFamilyName", familyName="InstanceFamilyName",
styleName="InstanceStyleName", styleName="InstanceStyleName",
postScriptFontName="InstancePostscriptName", postScriptFontName="InstancePostscriptName",
@ -268,7 +284,7 @@ def test_read_v5_document_simple(datadir):
filename="instances/instanceTest2.ufo", filename="instances/instanceTest2.ufo",
path=posix(str((datadir / "instances/instanceTest2.ufo").resolve())), path=posix(str((datadir / "instances/instanceTest2.ufo").resolve())),
name="instance.ufo2", name="instance.ufo2",
designLocation={"weight": 500.0, "width": (400.0, 300.0)}, designLocation={"Weight": 500.0, "Width": (400.0, 300.0)},
familyName="InstanceFamilyName", familyName="InstanceFamilyName",
styleName="InstanceStyleName", styleName="InstanceStyleName",
postScriptFontName="InstancePostscriptName", postScriptFontName="InstancePostscriptName",
@ -278,16 +294,16 @@ def test_read_v5_document_simple(datadir):
"arrow": { "arrow": {
"unicodes": [101, 201, 301], "unicodes": [101, 201, 301],
"note": "A note about this glyph", "note": "A note about this glyph",
"instanceLocation": {"weight": 120.0, "width": 100.0}, "instanceLocation": {"Weight": 120.0, "Width": 100.0},
"masters": [ "masters": [
{ {
"font": "master.ufo1", "font": "master.ufo1",
"location": {"weight": 20.0, "width": 20.0}, "location": {"Weight": 20.0, "Width": 20.0},
"glyphName": "BB", "glyphName": "BB",
}, },
{ {
"font": "master.ufo2", "font": "master.ufo2",
"location": {"weight": 900.0, "width": 900.0}, "location": {"Weight": 900.0, "Width": 900.0},
"glyphName": "CC", "glyphName": "CC",
}, },
], ],
@ -296,17 +312,17 @@ def test_read_v5_document_simple(datadir):
}, },
), ),
InstanceDescriptor( InstanceDescriptor(
locationLabel="asdf", locationLabel="Some Style",
), ),
InstanceDescriptor( InstanceDescriptor(
designLocation={"weight": 600.0, "width": (401.0, 420.0)}, designLocation={"Weight": 600.0, "Width": (401.0, 420.0)},
), ),
InstanceDescriptor( InstanceDescriptor(
designLocation={"weight": 10.0, "Italic": 0.0}, designLocation={"Weight": 10.0, "Italic": 0.0},
userLocation={"width": 100.0}, userLocation={"Width": 100.0},
), ),
InstanceDescriptor( InstanceDescriptor(
userLocation={"weight": 300.0, "width": 130.0, "Italic": 1.0}, userLocation={"Weight": 300.0, "Width": 130.0, "Italic": 1.0},
), ),
], ],
) )

View File

@ -19,7 +19,7 @@ def test_instance_getStatNames(datadir):
def test_not_all_ordering_specified_and_translations(datadir): def test_not_all_ordering_specified_and_translations(datadir):
doc = DesignSpaceDocument.fromfile(datadir / "test_v5.designspace") doc = DesignSpaceDocument.fromfile(datadir / "test_v5.designspace")
assert getStatNames(doc, {"weight": 200, "width": 125, "Italic": 1}) == StatNames( assert getStatNames(doc, {"Weight": 200, "Width": 125, "Italic": 1}) == StatNames(
familyNames={ familyNames={
"en": "MasterFamilyName", "en": "MasterFamilyName",
"fr": "Montserrat", "fr": "Montserrat",

View File

@ -15,7 +15,7 @@ def test_getStatAxes(datadir):
doc = DesignSpaceDocument.fromfile(datadir / "test_v5.designspace") doc = DesignSpaceDocument.fromfile(datadir / "test_v5.designspace")
assert getStatAxes( assert getStatAxes(
doc, {"Italic": 0, "width": Range(50, 150), "weight": Range(200, 900)} doc, {"Italic": 0, "Width": Range(50, 150), "Weight": Range(200, 900)}
) == [ ) == [
{ {
"values": [ "values": [
@ -82,7 +82,7 @@ def test_getStatAxes(datadir):
"rangeMinValue": 150.0, "rangeMinValue": 150.0,
}, },
], ],
"name": {"en": "width", "fr": "Chasse"}, "name": {"en": "Width", "fr": "Chasse"},
"ordering": 1, "ordering": 1,
"tag": "wdth", "tag": "wdth",
}, },
@ -96,7 +96,7 @@ def test_getStatAxes(datadir):
}, },
] ]
assert getStatAxes(doc, {"Italic": 1, "width": 100, "weight": Range(400, 700)}) == [ assert getStatAxes(doc, {"Italic": 1, "Width": 100, "Weight": Range(400, 700)}) == [
{ {
"values": [ "values": [
{ {
@ -129,7 +129,7 @@ def test_getStatAxes(datadir):
"values": [ "values": [
{"flags": 3, "name": {"en": "Normal"}, "value": 100.0}, {"flags": 3, "name": {"en": "Normal"}, "value": 100.0},
], ],
"name": {"en": "width", "fr": "Chasse"}, "name": {"en": "Width", "fr": "Chasse"},
"ordering": 1, "ordering": 1,
"tag": "wdth", "tag": "wdth",
}, },
@ -148,7 +148,7 @@ def test_getStatLocations(datadir):
doc = DesignSpaceDocument.fromfile(datadir / "test_v5.designspace") doc = DesignSpaceDocument.fromfile(datadir / "test_v5.designspace")
assert getStatLocations( assert getStatLocations(
doc, {"Italic": 0, "width": Range(50, 150), "weight": Range(200, 900)} doc, {"Italic": 0, "Width": Range(50, 150), "Weight": Range(200, 900)}
) == [ ) == [
{ {
"flags": 0, "flags": 0,
@ -157,7 +157,7 @@ def test_getStatLocations(datadir):
}, },
] ]
assert getStatLocations( assert getStatLocations(
doc, {"Italic": 1, "width": Range(50, 150), "weight": Range(200, 900)} doc, {"Italic": 1, "Width": Range(50, 150), "Weight": Range(200, 900)}
) == [ ) == [
{ {
"flags": 0, "flags": 0,