File: test_background_set.py

package info (click to toggle)
blender 4.3.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 309,564 kB
  • sloc: cpp: 2,385,210; python: 330,236; ansic: 280,972; xml: 2,446; sh: 972; javascript: 317; makefile: 170
file content (69 lines) | stat: -rw-r--r-- 2,195 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# SPDX-FileCopyrightText: 2017-2022 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later

# ############################################################
# Importing - Same For All Render Layer Tests
# ############################################################

import unittest

from view_layer_common import (
    ViewLayerTesting,
    setup_extra_arguments,
)


# ############################################################
# Testing
# ############################################################

class UnitTesting(ViewLayerTesting):
    def test_background_set(self):
        """
        See if background sets are properly added and removed
        """
        import bpy

        background_scene = bpy.data.scenes[0]
        main_scene = bpy.data.scenes.new('main')
        bpy.context.window.scene = main_scene

        # Update depsgraph.
        bpy.context.view_layer.update()

        # Safety check, there should be no objects in thew newly created scene.
        self.assertEqual(0, len(bpy.context.depsgraph.objects))

        # Now set the background set, and objects relationship.
        main_scene.background_set = background_scene
        background_scene.objects[0].parent = background_scene.objects[1]

        # Update depsgraph.
        bpy.context.view_layer.update()

        # Test if objects were properly added to depsgraph.
        self.assertEqual(3, len(bpy.context.depsgraph.objects))

        # We now check if the objects are properly flagged as from set
        # These objects can't be possible nor show their origins or
        # relationship lines
        for ob in bpy.context.depsgraph.objects:
            self.assertTrue(ob.is_from_set)

        # Test if removing is working fine.
        main_scene.background_set = None

        # Update depsgraph.
        bpy.context.view_layer.update()

        self.assertEqual(0, len(bpy.context.depsgraph.objects))


# ############################################################
# Main - Same For All Render Layer Tests
# ############################################################

if __name__ == '__main__':
    UnitTesting._extra_arguments = setup_extra_arguments(__file__)
    unittest.main()