Better py2/py3 compatibility

This commit is contained in:
adam-urbanczyk
2018-02-02 16:34:37 +01:00
parent fb9ce86269
commit 6bb4898371
2 changed files with 12 additions and 9 deletions

View File

@ -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)