test_GLIF{1,2}: use itertools.islice to skip first line with xml declaration
This commit is contained in:
parent
7bbdf6eef2
commit
c51ca22a6b
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
||||
import unittest
|
||||
from ufoLib.glifLib import GlifLibError, readGlyphFromString, writeGlyphToString
|
||||
from ufoLib.test.testSupport import Glyph, stripText
|
||||
from itertools import islice
|
||||
|
||||
try:
|
||||
basestring
|
||||
@ -25,9 +26,8 @@ class TestGLIF1(unittest.TestCase):
|
||||
glyph = Glyph()
|
||||
exec(py, {"glyph" : glyph, "pointPen" : glyph})
|
||||
glif = writeGlyphToString(glyph.name, glyphObject=glyph, drawPointsFunc=glyph.drawPoints, formatVersion=1, validate=True)
|
||||
lines = iter(glif.splitlines())
|
||||
next(lines) # discard the first line containing the xml declaration
|
||||
return "\n".join(lines)
|
||||
# discard the first line containing the xml declaration
|
||||
return "\n".join(islice(glif.splitlines(), 1, None))
|
||||
|
||||
def glifToPy(self, glif):
|
||||
glif = stripText(glif)
|
||||
|
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
||||
import unittest
|
||||
from ufoLib.glifLib import GlifLibError, readGlyphFromString, writeGlyphToString
|
||||
from ufoLib.test.testSupport import Glyph, stripText
|
||||
from itertools import islice
|
||||
|
||||
try:
|
||||
basestring
|
||||
@ -25,9 +26,8 @@ class TestGLIF2(unittest.TestCase):
|
||||
glyph = Glyph()
|
||||
exec(py, {"glyph" : glyph, "pointPen" : glyph})
|
||||
glif = writeGlyphToString(glyph.name, glyphObject=glyph, drawPointsFunc=glyph.drawPoints, formatVersion=2, validate=True)
|
||||
lines = iter(glif.splitlines())
|
||||
next(lines) # discard the first line containing the xml declaration
|
||||
return "\n".join(lines)
|
||||
# discard the first line containing the xml declaration
|
||||
return "\n".join(islice(glif.splitlines(), 1, None))
|
||||
|
||||
def glifToPy(self, glif):
|
||||
glif = stripText(glif)
|
||||
|
Loading…
x
Reference in New Issue
Block a user