Esempio n. 1
0
 def test_import_badformat(self):
     filename = 'test-files/bad_format.step'  # file exists, but is not a valid STEP file
     thing = Part.importer('step')(filename)
     # exception not raised before object is formed
     with self.assertRaises(ValueError):
         with suppress_stdout_stderr():
             thing.local_obj
Esempio n. 2
0
 def test_import_unicode(self):
     filename = u'test-files/cube.step'
     with suppress_stdout_stderr():
         cube = Part.importer('step')(filename)
         self.assertEqual(type(cube).__name__, 'cube_step')
         self.assertAlmostEqual(cube.bounding_box.xmin, -0.5)
         self.assertAlmostEqual(cube.bounding_box.xmax, 0.5)
Esempio n. 3
0
 def test_multipart_assembly(self):
     # When imported as an Assembly, each individual mesh
     # is imported as a component Part of the resulting Assembly.
     filename = 'test-files/red_cube_blue_cylinder.step'
     with suppress_stdout_stderr():
         thing = Assembly.importer('step')(filename)
         self.assertEqual(len(thing.components), 2)
         self.assertEqual(len(thing.constraints), 2)
Esempio n. 4
0
 def test_multipart_part(self):
     # When imported as a Part, geometry is unioned together
     filename = 'test-files/red_cube_blue_cylinder.step'
     with suppress_stdout_stderr():
         thing = Part.importer('step')(filename)
         # cylinder {5 < x < 15}, box {-10 < x < 0}
         # combined they should be {-10 < x < 15}
         self.assertAlmostEqual(thing.bounding_box.xmin, -10)
         self.assertAlmostEqual(thing.bounding_box.xmax, 15)
Esempio n. 5
0
    def test_basic(self, mock_serverobj, mock_webbrowser_open):
        # setup mocks
        mock_server = mock.MagicMock(server_address=('abc', 123))
        mock_serverobj.return_value = mock_server

        part = Box()
        disp_env = display.web.WebDisplayEnv()
        with suppress_stdout_stderr():
            disp_env.display(part)

        # webbrowser.open called
        self.assertEquals(len(mock_webbrowser_open.call_args_list), 1)
        mock_webbrowser_open.assert_called_once_with('http://abc:123/')

        # SocketServer.ThreadingTCPServer.serve_forever called
        mock_server.serve_forever.assert_called_once_with()
Esempio n. 6
0
 def test_import(self):
     filename = 'test-files/cube.step'
     with suppress_stdout_stderr():
         cube = Part.importer('step')(filename)
         self.assertAlmostEqual(cube.bounding_box.xmin, -0.5)
         self.assertAlmostEqual(cube.bounding_box.xmax, 0.5)