-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconftest.py
More file actions
66 lines (52 loc) · 2.12 KB
/
conftest.py
File metadata and controls
66 lines (52 loc) · 2.12 KB
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
57
58
59
60
61
62
63
64
65
66
"""
Root conftest.py — installs bpy mock before any test collection.
This must be at the repository root so it runs before pytest attempts
to import blender_vcs/__init__.py (which imports bpy at module level).
"""
import sys
from unittest.mock import MagicMock
def _build_mock_bpy():
bpy = MagicMock()
for prop in (
"StringProperty", "BoolProperty", "IntProperty", "FloatProperty",
"EnumProperty", "FloatVectorProperty", "IntVectorProperty",
"PointerProperty", "CollectionProperty",
):
setattr(bpy.props, prop, MagicMock(return_value=None))
bpy.types.Operator = type("Operator", (), {"bl_idname": "", "bl_label": ""})
bpy.types.Panel = type("Panel", (), {})
bpy.types.AddonPreferences = type("AddonPreferences", (), {})
bpy.types.WindowManager = MagicMock()
bpy.types.Mesh = MagicMock()
bpy.types.Object = MagicMock()
bpy.utils.register_class = MagicMock()
bpy.utils.unregister_class = MagicMock()
bpy.data.meshes = MagicMock()
bpy.data.objects = MagicMock()
bpy.data.cameras = MagicMock()
bpy.data.lights = MagicMock()
bpy.data.armatures = MagicMock()
bpy.data.materials = MagicMock()
bpy.data.collections = MagicMock()
bpy.data.libraries = []
bpy.data.images = []
bpy.context.window_manager = MagicMock()
bpy.context.blend_data = MagicMock()
bpy.context.blend_data.filepath = "/tmp/test.blend"
bpy.context.scene = MagicMock()
bpy.context.scene.objects = []
bpy.context.evaluated_depsgraph_get = MagicMock()
bpy.context.preferences = MagicMock()
bpy.context.selected_objects = []
bpy.ops.wm = MagicMock()
bpy.ops.object = MagicMock()
bpy.ops.outliner = MagicMock()
# Scene collection (used by clear_scene and reconstruct_scene)
bpy.context.scene.collection.objects = MagicMock()
bpy.context.scene.collection.objects.__iter__ = MagicMock(return_value=iter([]))
bpy.context.scene.collection.children = MagicMock()
bpy.path.abspath = lambda x: x
bpy.app.binary_path = "/usr/bin/blender"
return bpy
if "bpy" not in sys.modules:
sys.modules["bpy"] = _build_mock_bpy()