Layers unittest: isolate the depsgraph crash in individual tests

(and re-order the tests alphabetically)
This commit is contained in:
Dalai Felinto 2017-03-02 09:37:10 +01:00
parent 869f2940c2
commit a65af5d0cf
5 changed files with 103 additions and 26 deletions

View File

@ -56,15 +56,10 @@ macro(RENDER_LAYER_TEST test_name)
)
endmacro()
RENDER_LAYER_TEST(scene_write_read)
RENDER_LAYER_TEST(scene_copy)
RENDER_LAYER_TEST(layer_syncinc)
RENDER_LAYER_TEST(layer_linking)
RENDER_LAYER_TEST(collection_rename)
RENDER_LAYER_TEST(active_collection)
RENDER_LAYER_TEST(object_delete)
RENDER_LAYER_TEST(link)
RENDER_LAYER_TEST(operator_context)
RENDER_LAYER_TEST(collection_rename)
RENDER_LAYER_TEST(evaluation_visibility_a)
RENDER_LAYER_TEST(evaluation_visibility_b)
RENDER_LAYER_TEST(object_add_cylinder)
RENDER_LAYER_TEST(object_add_empty)
RENDER_LAYER_TEST(object_add_torus)
@ -72,5 +67,12 @@ RENDER_LAYER_TEST(object_add_no_collection_cylinder)
RENDER_LAYER_TEST(object_add_no_collection_empty)
RENDER_LAYER_TEST(object_add_no_collection_torus)
RENDER_LAYER_TEST(object_copy)
RENDER_LAYER_TEST(evaluation_visibility_a)
RENDER_LAYER_TEST(evaluation_visibility_b)
RENDER_LAYER_TEST(object_delete)
RENDER_LAYER_TEST(object_link_a)
RENDER_LAYER_TEST(object_link_b)
RENDER_LAYER_TEST(object_link_c)
RENDER_LAYER_TEST(operator_context)
RENDER_LAYER_TEST(layer_linking)
RENDER_LAYER_TEST(layer_syncinc)
RENDER_LAYER_TEST(scene_copy)
RENDER_LAYER_TEST(scene_write_read)

View File

@ -336,3 +336,9 @@ class RenderLayerTesting(unittest.TestCase):
collection = layer.collections[0]
self.assertEqual(len(collection.objects), 1, "New collection is empty")
def do_object_link(self, master_collection):
import bpy
self.assertEqual(master_collection.name, "Master Collection")
self.assertEqual(master_collection, bpy.context.scene.master_collection)
master_collection.objects.link(bpy.data.objects.new('object', None))

View File

@ -0,0 +1,40 @@
# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.py -- --testdir="/data/lib/tests/"
# ############################################################
# Importing - Same For All Render Layer Tests
# ############################################################
import unittest
import os, sys
sys.path.append(os.path.dirname(__file__))
from render_layer_common import *
# ############################################################
# Testing
# ############################################################
class UnitTesting(RenderLayerTesting):
def test_object_link_scene(self):
"""
See if we can link objects
"""
import bpy
master_collection = bpy.context.scene.master_collection
self.do_object_link(master_collection)
# ############################################################
# Main - Same For All Render Layer Tests
# ############################################################
if __name__ == '__main__':
import sys
extra_arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 2:] if "--" in sys.argv else [])
UnitTesting._extra_arguments = extra_arguments
unittest.main()

View File

@ -17,28 +17,14 @@ from render_layer_common import *
# ############################################################
class UnitTesting(RenderLayerTesting):
def do_link(self, master_collection):
import bpy
self.assertEqual(master_collection.name, "Master Collection")
self.assertEqual(master_collection, bpy.context.scene.master_collection)
master_collection.objects.link(bpy.data.objects.new('object', None))
def test_link_scene(self):
"""
See if we can link objects
"""
import bpy
master_collection = bpy.context.scene.master_collection
self.do_link(master_collection)
def test_link_context(self):
def test_object_link_context(self):
"""
See if we can link objects via bpy.context.scene_collection
"""
import bpy
bpy.context.scene.render_layers.active_index = len(bpy.context.scene.render_layers) - 1
master_collection = bpy.context.scene_collection
self.do_link(master_collection)
self.do_object_link(master_collection)
# ############################################################

View File

@ -0,0 +1,43 @@
# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.py -- --testdir="/data/lib/tests/"
# ############################################################
# Importing - Same For All Render Layer Tests
# ############################################################
import unittest
import os, sys
sys.path.append(os.path.dirname(__file__))
from render_layer_common import *
# ############################################################
# Testing
# ############################################################
class UnitTesting(RenderLayerTesting):
def test_object_link_reload(self):
"""
See if we can link objects and not crash
"""
import bpy
master_collection = bpy.context.scene.master_collection
self.do_object_link(master_collection)
# force depsgraph to update
bpy.ops.wm.read_factory_settings()
# ############################################################
# Main - Same For All Render Layer Tests
# ############################################################
if __name__ == '__main__':
import sys
extra_arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 2:] if "--" in sys.argv else [])
UnitTesting._extra_arguments = extra_arguments
unittest.main()