From 0c5014aaef854bba096bdaab7d6807fcfd45d7d0 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 14 Feb 2020 11:02:22 +0100 Subject: Cleanup: Deduplicate some code in new blenfile io/linking tests. --- tests/python/bl_blendfile_liblink.py | 37 ++++++------------------------------ 1 file changed, 6 insertions(+), 31 deletions(-) (limited to 'tests/python/bl_blendfile_liblink.py') 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) -- cgit v1.2.3