Files
test/tests/python/object_edit.py
Hans Goudey 8be01c2ce0 Fix #147270: Smooth by angle asset detection broken
Previous attempts:
- 6d884e0da5
- 80e8493c11

It seems `BLI_path_normalize` was doing more than necessary and that
was getting in the way. This PR adds an automated test to avoid the issue
in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/148069
2025-10-14 20:50:36 +02:00

40 lines
1.3 KiB
Python

# 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()