test_evaluation_visibility_j.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # ############################################################
  2. # Importing - Same For All Render Layer Tests
  3. # ############################################################
  4. import unittest
  5. import os
  6. import sys
  7. from view_layer_common import *
  8. # ############################################################
  9. # Testing
  10. # ############################################################
  11. class UnitTesting(ViewLayerTesting):
  12. def test_visibility_nested(self):
  13. """
  14. See if the depsgraph evaluation is correct
  15. """
  16. import bpy
  17. # delete all initial objects
  18. while bpy.data.objects:
  19. bpy.data.objects.remove(bpy.data.objects[0])
  20. # delete all initial collections
  21. scene = bpy.context.scene
  22. master_collection = scene.master_collection
  23. while master_collection.collections:
  24. master_collection.collections.remove(master_collection.collections[0])
  25. collection_parent = master_collection.collections.new('parent')
  26. collection_nested = collection_parent.collections.new('child linked')
  27. ob = bpy.data.objects.new('An Empty', None)
  28. collection_nested.objects.link(ob)
  29. layer_collection = bpy.context.view_layer.collections.link(master_collection)
  30. self.assertTrue(layer_collection.enabled)
  31. # Update depsgraph.
  32. bpy.context.view_layer.update()
  33. self.assertTrue(ob.visible_get())
  34. layer_collection.enabled = False
  35. self.assertFalse(layer_collection.enabled)
  36. # Update depsgraph.
  37. bpy.context.view_layer.update()
  38. self.assertFalse(ob.visible_get())
  39. # ############################################################
  40. # Main - Same For All Render Layer Tests
  41. # ############################################################
  42. if __name__ == '__main__':
  43. UnitTesting._extra_arguments = setup_extra_arguments(__file__)
  44. unittest.main()