test_evaluation_selectability_b.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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_selectability(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('Selectability 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_collection_mom.collections.new("Kid")
  25. scene_collection_kid.objects.link(cube)
  26. layer_collection_mom = layer.collections.link(scene_collection_mom)
  27. layer_collection_kid = layer.collections.link(scene_collection_kid)
  28. bpy.context.view_layer.update() # update depsgraph
  29. cube.select_set(True)
  30. layer_collection_mom.collections[layer_collection_kid.name].enabled = False
  31. layer_collection_kid.enabled = False
  32. bpy.context.view_layer.update() # update depsgraph
  33. self.assertFalse(cube.visible_get(), "Cube should be invisible")
  34. self.assertFalse(cube.select_get(), "Cube should be unselected")
  35. # ############################################################
  36. # Main - Same For All Render Layer Tests
  37. # ############################################################
  38. if __name__ == '__main__':
  39. UnitTesting._extra_arguments = setup_extra_arguments(__file__)
  40. unittest.main()