ufoLib: fix doctests failing on py27 for unicode_literals

I hate doctests.
This commit is contained in:
Cosimo Lupo 2018-10-18 13:58:47 +01:00
parent 8ba98afb92
commit b23a208805
No known key found for this signature in database
GPG Key ID: 59D54DB0C9976482
3 changed files with 46 additions and 22 deletions

View File

@ -89,10 +89,10 @@ def findKnownKerningGroups(groups):
... "foo" : None, ... "foo" : None,
... } ... }
>>> first, second = findKnownKerningGroups(testGroups) >>> first, second = findKnownKerningGroups(testGroups)
>>> sorted(first) >>> sorted(first) == ['@MMK_L_1', '@MMK_L_2', '@MMK_L_3']
['@MMK_L_1', '@MMK_L_2', '@MMK_L_3'] True
>>> sorted(second) >>> sorted(second) == ['@MMK_R_1', '@MMK_R_2', '@MMK_R_3']
['@MMK_R_1', '@MMK_R_2', '@MMK_R_3'] True
""" """
knownFirstGroupPrefixes = [ knownFirstGroupPrefixes = [
"@MMK_L_" "@MMK_L_"

View File

@ -57,8 +57,8 @@ def deprecated(msg=""):
... print("hello world") ... print("hello world")
>>> some_function() >>> some_function()
hello world hello world
>>> some_function.__doc__ >>> some_function.__doc__ == "I just print 'hello world'."
"I just print 'hello world'." True
""" """
def deprecated_decorator(func): def deprecated_decorator(func):

View File

@ -841,27 +841,39 @@ def groupsValidator(value):
(True, None) (True, None)
>>> groups = {"" : ["A"]} >>> groups = {"" : ["A"]}
>>> groupsValidator(groups) >>> valid, msg = groupsValidator(groups)
(False, 'A group has an empty name.') >>> valid
False
>>> print(msg)
A group has an empty name.
>>> groups = {"public.awesome" : ["A"]} >>> groups = {"public.awesome" : ["A"]}
>>> groupsValidator(groups) >>> groupsValidator(groups)
(True, None) (True, None)
>>> groups = {"public.kern1." : ["A"]} >>> groups = {"public.kern1." : ["A"]}
>>> groupsValidator(groups) >>> valid, msg = groupsValidator(groups)
(False, 'The group data contains a kerning group with an incomplete name.') >>> valid
False
>>> print(msg)
The group data contains a kerning group with an incomplete name.
>>> groups = {"public.kern2." : ["A"]} >>> groups = {"public.kern2." : ["A"]}
>>> groupsValidator(groups) >>> valid, msg = groupsValidator(groups)
(False, 'The group data contains a kerning group with an incomplete name.') >>> valid
False
>>> print(msg)
The group data contains a kerning group with an incomplete name.
>>> groups = {"public.kern1.A" : ["A"], "public.kern2.A" : ["A"]} >>> groups = {"public.kern1.A" : ["A"], "public.kern2.A" : ["A"]}
>>> groupsValidator(groups) >>> groupsValidator(groups)
(True, None) (True, None)
>>> groups = {"public.kern1.A1" : ["A"], "public.kern1.A2" : ["A"]} >>> groups = {"public.kern1.A1" : ["A"], "public.kern1.A2" : ["A"]}
>>> groupsValidator(groups) >>> valid, msg = groupsValidator(groups)
(False, 'The glyph "A" occurs in too many kerning groups.') >>> valid
False
>>> print(msg)
The glyph "A" occurs in too many kerning groups.
""" """
bogusFormatMessage = "The group data is not in the correct format." bogusFormatMessage = "The group data is not in the correct format."
if not isDictEnough(value): if not isDictEnough(value):
@ -908,12 +920,18 @@ def kerningValidator(data):
(True, None) (True, None)
>>> kerning = {"A" : ["B"]} >>> kerning = {"A" : ["B"]}
>>> kerningValidator(kerning) >>> valid, msg = kerningValidator(kerning)
(False, 'The kerning data is not in the correct format.') >>> valid
False
>>> print(msg)
The kerning data is not in the correct format.
>>> kerning = {"A" : {"B" : "100"}} >>> kerning = {"A" : {"B" : "100"}}
>>> kerningValidator(kerning) >>> valid, msg = kerningValidator(kerning)
(False, 'The kerning data is not in the correct format.') >>> valid
False
>>> print(msg)
The kerning data is not in the correct format.
""" """
bogusFormatMessage = "The kerning data is not in the correct format." bogusFormatMessage = "The kerning data is not in the correct format."
if not isinstance(data, Mapping): if not isinstance(data, Mapping):
@ -975,8 +993,11 @@ def fontLibValidator(value):
public.glyphOrder is not properly formatted: expected list or tuple,... public.glyphOrder is not properly formatted: expected list or tuple,...
>>> lib = {"public.glyphOrder" : ["A", 1, "B"]} >>> lib = {"public.glyphOrder" : ["A", 1, "B"]}
>>> fontLibValidator(lib) >>> valid, msg = fontLibValidator(lib)
(False, 'public.glyphOrder is not properly formatted: expected basestring, found int') >>> valid
False
>>> print(msg) # doctest: +ELLIPSIS
public.glyphOrder is not properly formatted: expected basestring,...
""" """
if not isDictEnough(value): if not isDictEnough(value):
reason = "expected a dictionary, found %s" % type(value).__name__ reason = "expected a dictionary, found %s" % type(value).__name__
@ -1020,8 +1041,11 @@ def glyphLibValidator(value):
(True, None) (True, None)
>>> lib = {"public.markColor" : 1} >>> lib = {"public.markColor" : 1}
>>> glyphLibValidator(lib) >>> valid, msg = glyphLibValidator(lib)
(False, 'public.markColor is not properly formatted.') >>> valid
False
>>> print(msg)
public.markColor is not properly formatted.
""" """
if not isDictEnough(value): if not isDictEnough(value):
reason = "expected a dictionary, found %s" % type(value).__name__ reason = "expected a dictionary, found %s" % type(value).__name__