WIP test documentLib. Add a warning if a findDefault can't find a suitable location.
This commit is contained in:
parent
07fb8abac3
commit
9d91c82bbe
@ -1202,8 +1202,10 @@ class DesignSpaceDocument(object):
|
|||||||
self.default = sourceDescriptor
|
self.default = sourceDescriptor
|
||||||
return sourceDescriptor
|
return sourceDescriptor
|
||||||
# failing that, well, fail. We don't want to guess any more.
|
# failing that, well, fail. We don't want to guess any more.
|
||||||
|
warnings.warn("Can't find a suitable default location in this document")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _prepAxesForBender(self):
|
def _prepAxesForBender(self):
|
||||||
"""
|
"""
|
||||||
Make the axis data we have available in
|
Make the axis data we have available in
|
||||||
|
@ -774,6 +774,27 @@ def test_incompleteRule(tmpdir):
|
|||||||
new.read(testDocPath1)
|
new.read(testDocPath1)
|
||||||
assert "No minimum or maximum defined in rule" in str(excinfo.value)
|
assert "No minimum or maximum defined in rule" in str(excinfo.value)
|
||||||
|
|
||||||
|
def test_documentLib(tmpdir):
|
||||||
|
# roundtrip test of the document lib with some nested data
|
||||||
|
tmpdir = str(tmpdir)
|
||||||
|
testDocPath1 = os.path.join(tmpdir, "testDocumentLibTest.designspace")
|
||||||
|
doc = DesignSpaceDocument()
|
||||||
|
a1 = AxisDescriptor()
|
||||||
|
a1.tag = "TAGA"
|
||||||
|
a1.name = "axisName_a"
|
||||||
|
a1.minimum = 0
|
||||||
|
a1.maximum = 1000
|
||||||
|
a1.default = 0
|
||||||
|
doc.addAxis(a1)
|
||||||
|
dummyData = dict(a=123, b=u"äbc"+chr(127921), c=[1,2,3], d={'a':123})
|
||||||
|
dummyKey = "org.fontTools.designspaceLib"
|
||||||
|
doc.lib = {dummyKey: dummyData}
|
||||||
|
doc.write(testDocPath1)
|
||||||
|
new = DesignSpaceDocument()
|
||||||
|
new.read(testDocPath1)
|
||||||
|
assert dummyKey in new.lib
|
||||||
|
assert new.lib[dummyKey] == dummyData
|
||||||
|
|
||||||
def __removeConditionMinimumMaximumDesignSpace(path):
|
def __removeConditionMinimumMaximumDesignSpace(path):
|
||||||
# only for testing, so we can make an invalid designspace file
|
# only for testing, so we can make an invalid designspace file
|
||||||
# without making the designSpaceDocument also support it.
|
# without making the designSpaceDocument also support it.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user