WIP uncomment test for conditions without min or max.
Add _axesAsDict to the test because there it is needed.
This commit is contained in:
parent
554aa362bd
commit
e4c90b9afe
@ -704,12 +704,12 @@ class BaseDocReader(object):
|
|||||||
cd['maximum'] = None
|
cd['maximum'] = None
|
||||||
cd['name'] = conditionElement.attrib.get("name")
|
cd['name'] = conditionElement.attrib.get("name")
|
||||||
# # test for things
|
# # test for things
|
||||||
# if cd.get('minimum') is None and cd.get('maximum') is None:
|
if cd.get('minimum') is None and cd.get('maximum') is None:
|
||||||
# if ruleObject.name is not None:
|
if ruleObject.name is not None:
|
||||||
# n = ruleObject.name
|
n = ruleObject.name
|
||||||
# else:
|
else:
|
||||||
# n = "%d" % len(rules)
|
n = "%d" % len(rules)
|
||||||
# raise DesignSpaceDocumentError("No minimum or maximum defined in rule \"%s\"." % n)
|
raise DesignSpaceDocumentError("No minimum or maximum defined in rule \"%s\"." % n)
|
||||||
cds.append(cd)
|
cds.append(cd)
|
||||||
return cds
|
return cds
|
||||||
|
|
||||||
|
@ -12,6 +12,23 @@ from fontTools.designspaceLib import (
|
|||||||
DesignSpaceDocument, SourceDescriptor, AxisDescriptor, RuleDescriptor,
|
DesignSpaceDocument, SourceDescriptor, AxisDescriptor, RuleDescriptor,
|
||||||
InstanceDescriptor, evaluateRule, processRules, posix, DesignSpaceDocumentError)
|
InstanceDescriptor, evaluateRule, processRules, posix, DesignSpaceDocumentError)
|
||||||
|
|
||||||
|
def _axesAsDict(axes):
|
||||||
|
"""
|
||||||
|
Make the axis data we have available in
|
||||||
|
"""
|
||||||
|
axesDict = {}
|
||||||
|
for axisDescriptor in axes:
|
||||||
|
d = {
|
||||||
|
'name': axisDescriptor.name,
|
||||||
|
'tag': axisDescriptor.tag,
|
||||||
|
'minimum': axisDescriptor.minimum,
|
||||||
|
'maximum': axisDescriptor.maximum,
|
||||||
|
'default': axisDescriptor.default,
|
||||||
|
'map': axisDescriptor.map,
|
||||||
|
}
|
||||||
|
axesDict[axisDescriptor.name] = d
|
||||||
|
return axesDict
|
||||||
|
|
||||||
|
|
||||||
def assert_equals_test_file(path, test_filename):
|
def assert_equals_test_file(path, test_filename):
|
||||||
with open(path) as fp:
|
with open(path) as fp:
|
||||||
@ -710,7 +727,7 @@ def test_rulesDocument(tmpdir):
|
|||||||
assert len(doc.rules) == 1
|
assert len(doc.rules) == 1
|
||||||
assert len(doc.rules[0].conditionSets) == 1
|
assert len(doc.rules[0].conditionSets) == 1
|
||||||
assert len(doc.rules[0].conditionSets[0]) == 2
|
assert len(doc.rules[0].conditionSets[0]) == 2
|
||||||
assert doc._axesAsDict() == {'axisName_a': {'map': [], 'name': 'axisName_a', 'default': 0, 'minimum': 0, 'maximum': 1000, 'tag': 'TAGA'}, 'axisName_b': {'map': [], 'name': 'axisName_b', 'default': 2000, 'minimum': 2000, 'maximum': 3000, 'tag': 'TAGB'}}
|
assert _axesAsDict(doc.axes) == {'axisName_a': {'map': [], 'name': 'axisName_a', 'default': 0, 'minimum': 0, 'maximum': 1000, 'tag': 'TAGA'}, 'axisName_b': {'map': [], 'name': 'axisName_b', 'default': 2000, 'minimum': 2000, 'maximum': 3000, 'tag': 'TAGB'}}
|
||||||
assert doc.rules[0].conditionSets == [[
|
assert doc.rules[0].conditionSets == [[
|
||||||
{'minimum': 0, 'maximum': 1000, 'name': 'axisName_a'},
|
{'minimum': 0, 'maximum': 1000, 'name': 'axisName_a'},
|
||||||
{'minimum': 0, 'maximum': 3000, 'name': 'axisName_b'}]]
|
{'minimum': 0, 'maximum': 3000, 'name': 'axisName_b'}]]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user