From b6cccca6617c795df4eef6a06f3f73dfdc962b15 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 16 Jun 2025 16:17:06 +0200 Subject: [PATCH] BMesh: Python: Add minimal API test for bmesh. Hopefully will avoid critical failures like #140451 in the future. --- tests/python/CMakeLists.txt | 5 +++++ tests/python/bl_pyapi_bmesh.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/python/bl_pyapi_bmesh.py diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt index 0375fbdec3b..78cd38d7a20 100644 --- a/tests/python/CMakeLists.txt +++ b/tests/python/CMakeLists.txt @@ -261,6 +261,11 @@ add_blender_test( --python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_text.py ) +add_blender_test( + script_pyapi_bmesh + --python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_bmesh.py +) + add_blender_test( script_pyapi_grease_pencil --python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_grease_pencil.py diff --git a/tests/python/bl_pyapi_bmesh.py b/tests/python/bl_pyapi_bmesh.py new file mode 100644 index 00000000000..3a7d4e4c5fe --- /dev/null +++ b/tests/python/bl_pyapi_bmesh.py @@ -0,0 +1,31 @@ +# SPDX-FileCopyrightText: 2025 Blender Authors +# +# SPDX-License-Identifier: Apache-2.0 + +# ./blender.bin --background --python tests/python/bl_pyapi_bmesh.py -- --verbose +import bmesh +import unittest + + +class TestBMeshBasic(unittest.TestCase): + + def test_create_uvsphere(self): + bm = bmesh.new() + bmesh.ops.create_uvsphere( + bm, + u_segments=8, + v_segments=5, + radius=1.0, + ) + + self.assertEqual(len(bm.verts), 34) + self.assertEqual(len(bm.edges), 72) + self.assertEqual(len(bm.faces), 40) + + bm.free() + + +if __name__ == "__main__": + import sys + sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []) + unittest.main()