Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <b.mont29@gmail.com>2020-02-14 13:02:22 +0300
committerBastien Montagne <b.mont29@gmail.com>2020-02-14 14:18:21 +0300
commit0c5014aaef854bba096bdaab7d6807fcfd45d7d0 (patch)
tree5fb3f0efd5555a997282f5aae5ff39bcf0b062f0 /tests/python/bl_blendfile_liblink.py
parent5ca7c85e105d910f554db4855c099a6b74e59886 (diff)
Cleanup: Deduplicate some code in new blenfile io/linking tests.
Diffstat (limited to 'tests/python/bl_blendfile_liblink.py')
-rw-r--r--tests/python/bl_blendfile_liblink.py37
1 files changed, 6 insertions, 31 deletions
diff --git a/tests/python/bl_blendfile_liblink.py b/tests/python/bl_blendfile_liblink.py
index 51dd989ece1..7d93d7c8455 100644
--- a/tests/python/bl_blendfile_liblink.py
+++ b/tests/python/bl_blendfile_liblink.py
@@ -3,35 +3,10 @@
# ./blender.bin --background -noaudio --python tests/python/bl_blendfile_liblink.py
import bpy
import os
-import pprint
+import sys
-
-class TestHelper:
-
- @staticmethod
- def id_to_uid(id_data):
- return (type(id_data).__name__,
- id_data.name,
- id_data.users,
- id_data.library.filepath if id_data.library else None)
-
- @classmethod
- def blender_data_to_tuple(cls, bdata):
- return sorted(tuple((cls.id_to_uid(k), sorted(tuple(cls.id_to_uid(vv) for vv in v)))
- for k, v in bdata.user_map().items()))
-
- @staticmethod
- def ensure_path(path):
- if not os.path.exists(path):
- os.makedirs(path)
-
- def run_all_tests(self):
- for inst_attr_id in dir(self):
- if not inst_attr_id.startswith("test_"):
- continue
- inst_attr = getattr(self, inst_attr_id)
- if callable(inst_attr):
- inst_attr()
+sys.path.append(os.path.dirname(os.path.realpath(__file__)))
+from bl_blendfile_utils import TestHelper
class TestBlendLibLinkSaveLoadBasic(TestHelper):
@@ -56,14 +31,14 @@ class TestBlendLibLinkSaveLoadBasic(TestHelper):
link_dir = os.path.join(output_path, "Mesh")
bpy.ops.wm.link(directory=link_dir, filename="LibMesh")
- orig_data = self.blender_data_to_tuple(bpy.data)
+ orig_data = self.blender_data_to_tuple(bpy.data, "orig_data")
output_path = os.path.join(output_dir, "blendfile.blend")
bpy.ops.wm.save_as_mainfile(filepath=output_path, check_existing=False, compress=False)
bpy.ops.wm.open_mainfile(filepath=output_path, load_ui=False)
- read_data = self.blender_data_to_tuple(bpy.data)
-
+ read_data = self.blender_data_to_tuple(bpy.data, "read_data")
+
assert(orig_data == read_data)