-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Pickle for geom and Shape * Color pickling * Plane pickling * Pickle forConstruction * Fix Vector pickling * Add tests * Add Matrix * Fix Plane --------- Co-authored-by: adam-urbanczyk <[email protected]>
- Loading branch information
1 parent
c063b94
commit 9e47392
Showing
4 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from pickle import loads, dumps | ||
|
||
from cadquery import ( | ||
Vector, | ||
Matrix, | ||
Plane, | ||
Location, | ||
Shape, | ||
Sketch, | ||
Assembly, | ||
Color, | ||
Workplane, | ||
) | ||
from cadquery.func import box | ||
|
||
from pytest import mark | ||
|
||
|
||
@mark.parametrize( | ||
"obj", | ||
[ | ||
Vector(2, 3, 4), | ||
Matrix(), | ||
Plane((-2, 1, 1)), | ||
Location(1, 2, 4), | ||
Sketch().rect(1, 1), | ||
Color("red"), | ||
Workplane().sphere(1), | ||
], | ||
) | ||
def test_simple(obj): | ||
|
||
assert isinstance(loads(dumps(obj)), type(obj)) | ||
|
||
|
||
def test_shape(): | ||
|
||
s = Shape(box(1, 1, 1).wrapped) | ||
|
||
assert isinstance(loads(dumps(s)), Shape) | ||
|
||
|
||
def test_assy(): | ||
|
||
assy = Assembly().add(box(1, 1, 1), color=Color("blue")).add(box(2, 2, 2)) | ||
|
||
assert isinstance(loads(dumps(assy)), Assembly) |