def test_setxyz_measures_distance(self): output = StringIO() t = GcodeTurtle(fd=output) prelude = output.getvalue() t.setxyz(20, 30, 40) start_e = t.e t.setxyz(30, 40, 50) stop_e = t.e distance = (stop_e - start_e) / t.extrusion_rate self.assertAlmostEqual(distance, 17.320508076)
def test_setxyz(self): output = StringIO() t = GcodeTurtle(fd=output) prelude = output.getvalue() t.setxyz(20, 30, 40) output_line = output.getvalue() output_line = output_line.replace(prelude, "") output_line_parts = output_line.split(" ") self.assertEqual(len(output_line_parts), 5) self.assertEqual(output_line[-1], "\n") self.assertEqual(output_line.count("\n"), 1) self.assertEqual(output_line_parts[0], "G1") self.assertEqual(output_line_parts[1], "X20.000") self.assertEqual(output_line_parts[2], "Y30.000") self.assertEqual(output_line_parts[3], "Z40.000") self.assertEqual(output_line_parts[4][0], "E")