-
Notifications
You must be signed in to change notification settings - Fork 483
Expand file tree
/
Copy pathtest_pickle.py
More file actions
56 lines (42 loc) · 955 Bytes
/
test_pickle.py
File metadata and controls
56 lines (42 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from pickle import loads, dumps
from cadquery import (
Vector,
Matrix,
Plane,
Location,
Shape,
Sketch,
Assembly,
Color,
Workplane,
Material,
)
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():
mat_1 = Material(
"test", description="Test material", density=1.0, densityUnit="lb/in^3"
)
assy = (
Assembly()
.add(box(1, 1, 1), color=Color("blue"), material=mat_1)
.add(box(2, 2, 2))
)
assert isinstance(loads(dumps(assy)), Assembly)