Tests the ability to remove a part from an assembly when the part has no parent. This may never happen in practice, but the case has to be covered for mypy to pass.
()
| 2485 | |
| 2486 | |
| 2487 | def test_remove_without_parent(): |
| 2488 | """ |
| 2489 | Tests the ability to remove a part from an assembly when the part has no parent. |
| 2490 | This may never happen in practice, but the case has to be covered for mypy to pass. |
| 2491 | """ |
| 2492 | |
| 2493 | # Create a root assembly |
| 2494 | assy = cq.Assembly(name="root") |
| 2495 | |
| 2496 | # Create a part and add it to the assembly |
| 2497 | part = cq.Workplane().box(1, 1, 1) |
| 2498 | assy.add(part, name="part") |
| 2499 | |
| 2500 | # Artificially remove the parent to cover a branching test case |
| 2501 | assy.children[0].parent = None |
| 2502 | |
| 2503 | # Remove the part |
| 2504 | assy.remove("part") |
| 2505 | |
| 2506 | assert len(assy.children) == 1 |
| 2507 | assert len(assy.objects) == 1 |
| 2508 | |
| 2509 | |
| 2510 | def test_step_color(tmpdir): |