kopia lustrzana https://github.com/EmbroidePy/pyembroidery
				
				
				
			update test code for gcode writing test
							rodzic
							
								
									bb763735ce
								
							
						
					
					
						commit
						34a317ddcc
					
				|  | @ -7,7 +7,6 @@ from pyembroidery import GenericWriter | |||
| 
 | ||||
| 
 | ||||
| class TestConverts(unittest.TestCase): | ||||
| 
 | ||||
|     def test_generic_write_stitch(self): | ||||
|         file1 = "convert.dst" | ||||
|         file2 = "convert.txt" | ||||
|  | @ -39,6 +38,30 @@ class TestConverts(unittest.TestCase): | |||
|         print("write generic: ", file1) | ||||
| 
 | ||||
|     def test_generic_write_gcode(self): | ||||
|         gcode_writer_dict = ( | ||||
|             { | ||||
|                 "scale": (-0.1, -0.1), | ||||
|                 "pattern_start": "(STITCH_COUNT: {stitch_total})\n" | ||||
|                 "(THREAD_COUNT: {color_change_count})\n" | ||||
|                 "(EXTENTS_LEFT: {extents_left:.3f})\n" | ||||
|                 "(EXTENTS_TOP: {extends_top:.3f})\n" | ||||
|                 "(EXTENTS_RIGHT: {extends_right:.3f})\n" | ||||
|                 "(EXTENTS_BOTTOM: {extends_bottom:.3f})\n" | ||||
|                 "(EXTENTS_WIDTH: {extends_width:.3f})\n" | ||||
|                 "(EXTENTS_HEIGHT: {extends_height:.3f})\n" | ||||
|                 "(COMMAND_STITCH: {stitch_count})\n" | ||||
|                 "(COMMAND_COLOR_CHANGE: {color_change_count})\n" | ||||
|                 "(COMMAND_TRIM: {trim_count})\n" | ||||
|                 "(COMMAND_STOP: {stop_count})\n" | ||||
|                 "(COMMAND_END: {end_count})\n", | ||||
|                 "metadata_entry": "({metadata_key}: {metadata_value})\n", | ||||
|                 "thread_entry": "(Thread{thread_index}: {thread_color} {thread_description} {thread_brand} {thread_catalog_number})\n", | ||||
|                 "stitch": "G00 X{x:.3f} Y{y:.3f}\nG00 Z{z:.1f}\n", | ||||
|                 "color_change": "M00\n", | ||||
|                 "stop": "M00\n", | ||||
|                 "end": "M30\n", | ||||
|             }, | ||||
|         ) | ||||
|         file1 = "file-gcode.gcode" | ||||
|         file2 = "file-generic.gcode" | ||||
|         pattern = get_fractal_pattern() | ||||
|  | @ -47,28 +70,7 @@ class TestConverts(unittest.TestCase): | |||
|             GenericWriter, | ||||
|             pattern, | ||||
|             file2, | ||||
|             { | ||||
|                 "scale": (-.1, -.1), | ||||
|                 "pattern_start": "(STITCH_COUNT: {stitch_total})\n" | ||||
|                                   "(THREAD_COUNT: {color_change_count})\n" | ||||
|                                   "(EXTENTS_LEFT: {extents_left:.3f})\n" | ||||
|                                   "(EXTENTS_TOP: {extends_top:.3f})\n" | ||||
|                                   "(EXTENTS_RIGHT: {extends_right:.3f})\n" | ||||
|                                   "(EXTENTS_BOTTOM: {extends_bottom:.3f})\n" | ||||
|                                   "(EXTENTS_WIDTH: {extends_width:.3f})\n" | ||||
|                                   "(EXTENTS_HEIGHT: {extends_height:.3f})\n" | ||||
|                                   "(COMMAND_STITCH: {stitch_count})\n" | ||||
|                                   "(COMMAND_COLOR_CHANGE: {color_change_count})\n" | ||||
|                                   "(COMMAND_TRIM: {trim_count})\n" | ||||
|                                   "(COMMAND_STOP: {stop_count})\n" | ||||
|                                   "(COMMAND_END: {end_count})\n", | ||||
|                 "metadata_entry": "({metadata_key}: {metadata_value})\n", | ||||
|                 "thread_entry": "(Thread{thread_index}: {thread_color} {thread_description} {thread_brand} {thread_catalog_number})\n", | ||||
|                 "stitch": "G00 X{x:.3f} Y{y:.3f}\nG00 Z{z:.1f}\n", | ||||
|                 "color_change": "M00\n", | ||||
|                 "stop": "M00\n", | ||||
|                 "end":  "M30\n", | ||||
|             }, | ||||
|             gcode_writer_dict, | ||||
|         ) | ||||
|         pattern.write(file1) | ||||
|         f1 = open(file1, "rb").read() | ||||
|  | @ -76,4 +78,3 @@ class TestConverts(unittest.TestCase): | |||
|         self.assertEqual(f1, f2) | ||||
|         self.addCleanup(os.remove, file1) | ||||
|         self.addCleanup(os.remove, file2) | ||||
| 
 | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Tatarize
						Tatarize