""" Tests basic workplane functionality """ # core modules import sys if sys.version_info.major == 2: import cStringIO as StringIO else: import io as StringIO # my modules from cadquery import * from cadquery import exporters from tests import BaseTest class TestExporters(BaseTest): def _exportBox(self, eType, stringsToFind): """ Exports a test object, and then looks for all of the supplied strings to be in the result returns the result in case the case wants to do more checks also """ p = Workplane("XY").box(1, 2, 3) s = StringIO.StringIO() exporters.exportShape(p, eType, s, 0.1) result = s.getvalue() for q in stringsToFind: self.assertTrue(result.find(q) > -1) return result def testSTL(self): self._exportBox(exporters.ExportTypes.STL, ['facet normal']) def testSVG(self): self._exportBox(exporters.ExportTypes.SVG, ['']) def testSTEP(self): self._exportBox(exporters.ExportTypes.STEP, ['FILE_SCHEMA']) def testTJS(self): self._exportBox(exporters.ExportTypes.TJS, [ 'vertices', 'formatVersion', 'faces'])