Better fix for checking line endings, use UnicodeIO instead of BytesIO
This commit is contained in:
parent
c9bdda2bc3
commit
828a58aacb
@ -4,7 +4,6 @@ from fontTools.misc.xmlWriter import XMLWriter
|
|||||||
from fontTools.ttLib.tables.ttProgram import Program
|
from fontTools.ttLib.tables.ttProgram import Program
|
||||||
from fontTools.misc.textTools import deHexStr
|
from fontTools.misc.textTools import deHexStr
|
||||||
import array
|
import array
|
||||||
import io
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import unittest
|
import unittest
|
||||||
@ -101,19 +100,19 @@ class ProgramTest(unittest.TestCase):
|
|||||||
assert BYTECODE == p.getBytecode()
|
assert BYTECODE == p.getBytecode()
|
||||||
|
|
||||||
def test_xml_indentation(self):
|
def test_xml_indentation(self):
|
||||||
with open(TTPROGRAM_TTX, 'rb') as f:
|
with open(TTPROGRAM_TTX, 'r') as f:
|
||||||
ttProgramXML = f.read().splitlines()
|
ttProgramXML = f.read()
|
||||||
p = Program()
|
p = Program()
|
||||||
p.fromBytecode(BYTECODE)
|
p.fromBytecode(BYTECODE)
|
||||||
ttfont = TestFont()
|
ttfont = TestFont()
|
||||||
buf = io.BytesIO()
|
buf = UnicodeIO()
|
||||||
writer = XMLWriter(buf)
|
writer = XMLWriter(buf)
|
||||||
try:
|
try:
|
||||||
p.toXML(writer, ttfont)
|
p.toXML(writer, ttfont)
|
||||||
finally:
|
finally:
|
||||||
output_string = buf.getvalue()
|
output_string = buf.getvalue()
|
||||||
buf.close()
|
buf.close()
|
||||||
assert output_string.splitlines() == ttProgramXML
|
assert output_string == ttProgramXML
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user