[Bf-blender-cvs] [06a74e78169] master: LibLink/Append tests: Add basic testing of `bpy.data.libraries.load` code.

Bastien Montagne noreply at git.blender.org
Thu Nov 11 14:56:31 CET 2021


Commit: 06a74e78169ff60082716c0bd85c0b76de6bb885
Author: Bastien Montagne
Date:   Thu Nov 11 14:54:26 2021 +0100
Branches: master
https://developer.blender.org/rB06a74e78169ff60082716c0bd85c0b76de6bb885

LibLink/Append tests: Add basic testing of `bpy.data.libraries.load` code.

===================================================================

M	tests/python/bl_blendfile_liblink.py

===================================================================

diff --git a/tests/python/bl_blendfile_liblink.py b/tests/python/bl_blendfile_liblink.py
index 760a1a15959..f7bd2308061 100644
--- a/tests/python/bl_blendfile_liblink.py
+++ b/tests/python/bl_blendfile_liblink.py
@@ -435,12 +435,45 @@ class TestBlendLibLibraryRelocate(TestBlendLibLinkHelper):
         assert(orig_data == relocate_data)
 
 
+class TestBlendLibDataLibrariesLoad(TestBlendLibLinkHelper):
+
+    def __init__(self, args):
+        self.args = args
+
+    def test_link_relocate(self):
+        output_dir = self.args.output_dir
+        output_lib_path = self.init_lib_data_basic()
+
+        # Simple link of a single Object, and reload.
+        self.reset_blender()
+
+        with bpy.data.libraries.load(filepath=output_lib_path) as lib_ctx:
+            lib_src, lib_link = lib_ctx
+
+            assert(len(lib_src.meshes) == 1)
+            assert(len(lib_src.objects) == 1)
+            assert(len(lib_src.collections) == 1)
+
+            assert(len(lib_link.meshes) == 0)
+            assert(len(lib_link.objects) == 0)
+            assert(len(lib_link.collections) == 0)
+
+            lib_link.collections.append(lib_src.collections[0])
+
+        # Linking happens when living the context manager.
+
+        assert(len(bpy.data.meshes) == 1)
+        assert(len(bpy.data.objects) == 1)  # This code does no instantiation.
+        assert(len(bpy.data.collections) == 1)
+
+
 TESTS = (
     TestBlendLibLinkSaveLoadBasic,
     TestBlendLibAppendBasic,
     TestBlendLibAppendReuseID,
     TestBlendLibLibraryReload,
     TestBlendLibLibraryRelocate,
+    TestBlendLibDataLibrariesLoad,
 )



More information about the Bf-blender-cvs mailing list