Use popPending methods

This commit is contained in:
Marcus Boyd
2021-03-08 14:22:47 +10:30
parent b316461b49
commit 7be6070534
2 changed files with 50 additions and 43 deletions

View File

@ -394,8 +394,7 @@ class TestCadQuery(BaseTest):
def testLoft(self):
"""
Test making a lofted solid
:return:
Test making a lofted solid
"""
s = Workplane("XY").circle(4.0).workplane(5.0).rect(2.0, 2.0).loft()
self.saveModel(s)
@ -405,10 +404,13 @@ class TestCadQuery(BaseTest):
# the resulting loft had a split on the side, not sure why really, i expected only 3 faces
self.assertEqual(7, s.faces().size())
def testLoftWithOneWireRaisesValueError(self):
s = Workplane("XY").circle(5)
def testLoftRaisesValueError(self):
s0 = Workplane().hLine(1) # no wires
with raises(ValueError):
s0.loft()
s1 = Workplane("XY").circle(5) # one wire
with self.assertRaises(ValueError) as cm:
s.loft()
s1.loft()
err = cm.exception
self.assertEqual(str(err), "More than one wire is required")
@ -551,6 +553,14 @@ class TestCadQuery(BaseTest):
self.assertEqual(2, result.vertices().size())
self.assertEqual(2, result.edges().size())
def testRevolveErrors(self):
"""
Test that revolve raises errors when used incorrectly.
"""
result = Workplane("XY").lineTo(0, 10).lineTo(5, 0)
with raises(ValueError):
result.revolve()
def testSpline(self):
"""
Tests construction of splines
@ -1040,6 +1050,11 @@ class TestCadQuery(BaseTest):
self.assertAlmostEqual(v1.getAngle(v2), math.pi / 4, 6)
# test for ValueError if pending wires is empty
w0 = Workplane().hLine(1).vLine(1)
with raises(ValueError):
w0.sweep(path)
# Test aux spine invalid input handling
with raises(ValueError):
result = (
@ -1655,10 +1670,13 @@ class TestCadQuery(BaseTest):
self.assertTrue(r.val().isValid())
self.assertEqual(r.faces().size(), 7)
# test ValueError when no solids found
w0 = Workplane().hLine(1).vLine(1).close()
# test errors
box0 = Workplane().box(1, 1, 1).faces(">Z").workplane().hLine(1)
with raises(ValueError):
w0.cutThruAll()
box0.cutThruAll()
no_box = Workplane().hLine(1).vLine(1).close()
with raises(ValueError):
no_box.cutThruAll()
def testCutToFaceOffsetNOTIMPLEMENTEDYET(self):
"""
@ -4290,3 +4308,8 @@ class TestCadQuery(BaseTest):
w4 = Workplane().circle(1).extrude(1)
with self.assertRaises(ValueError):
w4.ctx.popPendingWires()
# test via cutBlind
w5 = Workplane().circle(1).extrude(1)
with self.assertRaises(ValueError):
w5.cutBlind(-1)