diff --git a/cadquery/occ_impl/exporters.py b/cadquery/occ_impl/exporters.py index 703ae07b..175f2ae7 100644 --- a/cadquery/occ_impl/exporters.py +++ b/cadquery/occ_impl/exporters.py @@ -1,3 +1,4 @@ +from __future__ import unicode_literals from OCC.Visualization import Tesselator import cadquery @@ -119,7 +120,7 @@ def readAndDeleteFile(fileName): """ res = "" with open(fileName, 'r') as f: - res = f.read() + res = "{}".format(f.read()) os.remove(fileName) return res @@ -183,8 +184,8 @@ class AmfWriter(object): v2.text = str(t[1]) v3 = ET.SubElement(triangle, 'v3') v3.text = str(t[2]) - - ET.ElementTree(amf).write(outFile, encoding='ISO-8859-1') + + amf = ET.ElementTree(amf).write(outFile, xml_declaration=True) """ diff --git a/tests/TestExporters.py b/tests/TestExporters.py index 2192f4e6..db631bea 100644 --- a/tests/TestExporters.py +++ b/tests/TestExporters.py @@ -3,10 +3,7 @@ """ # core modules import sys -if sys.version_info.major == 2: - import cStringIO as StringIO -else: - import io as StringIO +import io # my modules from cadquery import * @@ -23,10 +20,15 @@ class TestExporters(BaseTest): returns the result in case the case wants to do more checks also """ 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) - result = s.getvalue() + result = '{}'.format(s.getvalue()) for q in stringsToFind: self.assertTrue(result.find(q) > -1)