test_evaluation_visibility_a.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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(self):
  13. """
  14. See if the depsgraph evaluation is correct
  15. """
  16. import bpy
  17. scene = bpy.context.scene
  18. window = bpy.context.window
  19. cube = bpy.data.objects.new('guinea pig', bpy.data.meshes.new('mesh'))
  20. layer = scene.view_layers.new('Visibility Test')
  21. layer.collections.unlink(layer.collections[0])
  22. window.view_layer = layer
  23. scene_collection_mom = scene.master_collection.collections.new("Mom")
  24. scene_collection_kid = scene.master_collection.collections.new("Kid")
  25. scene_collection_mom.objects.link(cube)
  26. scene_collection_kid.objects.link(cube)
  27. layer_collection_mom = layer.collections.link(scene_collection_mom)
  28. layer_collection_kid = layer.collections.link(scene_collection_kid)
  29. layer_collection_mom.enabled = False
  30. layer_collection_kid.enabled = True
  31. layer.update() # update depsgraph
  32. self.assertTrue(cube.visible_get(), "Object should be visible")
  33. # ############################################################
  34. # Main - Same For All Render Layer Tests
  35. # ############################################################
  36. if __name__ == '__main__':
  37. UnitTesting._extra_arguments = setup_extra_arguments(__file__)
  38. unittest.main()