MCPcopy
hub / github.com/CadQuery/cadquery / test_remove_without_parent

Function test_remove_without_parent

tests/test_assembly.py:2487–2507  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

2485
2486
2487def 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
2510def test_step_color(tmpdir):

Callers

nothing calls this directly

Calls 3

addMethod · 0.95
removeMethod · 0.95
boxMethod · 0.80

Tested by

no test coverage detected