File: object_edit.py

package info (click to toggle)
blender 5.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 329,128 kB
  • sloc: cpp: 2,489,823; python: 349,859; ansic: 261,364; xml: 2,103; sh: 999; javascript: 317; makefile: 193
file content (39 lines) | stat: -rw-r--r-- 1,313 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
# SPDX-FileCopyrightText: 2025 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later


import unittest
import bpy
import sys


class TestObjectEdit(unittest.TestCase):

    def setUp(self):
        if bpy.context.object and bpy.context.object.mode != 'OBJECT':
            bpy.ops.object.mode_set(mode='OBJECT')
        for mesh in [mesh for mesh in bpy.data.meshes]:
            bpy.data.meshes.remove(mesh)
        for ob in [ob for ob in bpy.data.objects]:
            bpy.data.objects.remove(ob)

    def test_auto_smooth_detection(self):
        bpy.ops.mesh.primitive_cube_add()
        ob = bpy.context.object
        bpy.ops.object.shade_auto_smooth(use_auto_smooth=True)
        bpy.ops.object.shade_auto_smooth(use_auto_smooth=True)
        bpy.ops.object.shade_auto_smooth(use_auto_smooth=True)
        bpy.ops.object.shade_auto_smooth(use_auto_smooth=True)
        self.assertEqual(len(ob.modifiers), 1)
        bpy.ops.object.shade_flat()
        self.assertEqual(len(ob.modifiers), 0)
        bpy.ops.object.shade_auto_smooth(use_auto_smooth=True)
        bpy.ops.object.shade_smooth()
        self.assertEqual(len(ob.modifiers), 0)


if __name__ == '__main__':
    import sys
    sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])
    unittest.main()