Better py2/py3 compatibility
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
from OCC.Visualization import Tesselator
|
from OCC.Visualization import Tesselator
|
||||||
|
|
||||||
import cadquery
|
import cadquery
|
||||||
@ -119,7 +120,7 @@ def readAndDeleteFile(fileName):
|
|||||||
"""
|
"""
|
||||||
res = ""
|
res = ""
|
||||||
with open(fileName, 'r') as f:
|
with open(fileName, 'r') as f:
|
||||||
res = f.read()
|
res = "{}".format(f.read())
|
||||||
|
|
||||||
os.remove(fileName)
|
os.remove(fileName)
|
||||||
return res
|
return res
|
||||||
@ -183,8 +184,8 @@ class AmfWriter(object):
|
|||||||
v2.text = str(t[1])
|
v2.text = str(t[1])
|
||||||
v3 = ET.SubElement(triangle, 'v3')
|
v3 = ET.SubElement(triangle, 'v3')
|
||||||
v3.text = str(t[2])
|
v3.text = str(t[2])
|
||||||
|
|
||||||
ET.ElementTree(amf).write(outFile, encoding='ISO-8859-1')
|
amf = ET.ElementTree(amf).write(outFile, xml_declaration=True)
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -3,10 +3,7 @@
|
|||||||
"""
|
"""
|
||||||
# core modules
|
# core modules
|
||||||
import sys
|
import sys
|
||||||
if sys.version_info.major == 2:
|
import io
|
||||||
import cStringIO as StringIO
|
|
||||||
else:
|
|
||||||
import io as StringIO
|
|
||||||
|
|
||||||
# my modules
|
# my modules
|
||||||
from cadquery import *
|
from cadquery import *
|
||||||
@ -23,10 +20,15 @@ class TestExporters(BaseTest):
|
|||||||
returns the result in case the case wants to do more checks also
|
returns the result in case the case wants to do more checks also
|
||||||
"""
|
"""
|
||||||
p = Workplane("XY").box(1, 2, 3)
|
p = Workplane("XY").box(1, 2, 3)
|
||||||
s = StringIO.StringIO()
|
|
||||||
|
if eType == exporters.ExportTypes.AMF:
|
||||||
|
s = io.BytesIO()
|
||||||
|
else:
|
||||||
|
s = io.StringIO()
|
||||||
|
|
||||||
exporters.exportShape(p, eType, s, 0.1)
|
exporters.exportShape(p, eType, s, 0.1)
|
||||||
|
|
||||||
result = s.getvalue()
|
result = '{}'.format(s.getvalue())
|
||||||
|
|
||||||
for q in stringsToFind:
|
for q in stringsToFind:
|
||||||
self.assertTrue(result.find(q) > -1)
|
self.assertTrue(result.find(q) > -1)
|
||||||
|
|||||||
Reference in New Issue
Block a user