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

Function test_modes

tests/test_sketch.py:68–104  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

66
67
68def test_modes():
69
70 # additive mode
71 s1 = Sketch().rect(2, 2).rect(1, 1, mode="a")
72
73 assert s1._faces.Area() == approx(4)
74 assert len(s1._faces.Faces()) == 2
75
76 # subtraction mode
77 s2 = Sketch().rect(2, 2).rect(1, 1, mode="s")
78
79 assert s2._faces.Area() == approx(4 - 1)
80 assert len(s2._faces.Faces()) == 1
81
82 # intersection mode
83 s3 = Sketch().rect(2, 2).rect(1, 1, mode="i")
84
85 assert s3._faces.Area() == approx(1)
86 assert len(s3._faces.Faces()) == 1
87
88 # construction mode
89 s4 = Sketch().rect(2, 2).rect(1, 1, mode="c", tag="t")
90
91 assert s4._faces.Area() == approx(4)
92 assert len(s4._faces.Faces()) == 1
93 assert s4._tags["t"][0].Area() == approx(1)
94
95 # construction mode requires tagging
96 with raises(ValueError):
97 Sketch().rect(2, 2).rect(1, 1, mode="c")
98
99 with raises(ValueError):
100 Sketch().rect(2, 2).rect(1, 1, mode="dummy")
101
102 # replace mode
103 s5 = Sketch().rect(1, 1).wires().offset(-0.1, mode="r").reset()
104 assert s5.val().Area() == approx(0.8 ** 2)
105
106
107def test_distribute():

Callers

nothing calls this directly

Calls 8

SketchClass · 0.90
resetMethod · 0.80
offsetMethod · 0.80
rectMethod · 0.45
AreaMethod · 0.45
FacesMethod · 0.45
wiresMethod · 0.45
valMethod · 0.45

Tested by

no test coverage detected