Files
blender/tests/python/bl_multires.py
Sean Kim 92e9a6d9f1 Tests: Add Multires Apply Base test
Adds a new file for testing the Multires Apply Base operator.

This is not included with the other modifier tests as it is a bit of an
exception - the modifier is not applied at the end for comparison
between the expected result and actual result.

Pull Request: https://projects.blender.org/blender/blender/pulls/141571
2025-07-08 22:17:36 +02:00

59 lines
1.4 KiB
Python

# SPDX-FileCopyrightText: 2025 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later */
__all__ = (
"main",
)
import unittest
import sys
import pathlib
import bpy
from mathutils import Vector
"""
blender -b --factory-startup --python tests/python/bl_object_modifier_multires.py -- --testdir tests/files/sculpting/
"""
args = None
class ApplyBase(unittest.TestCase):
def setUp(self):
bpy.ops.wm.open_mainfile(filepath=str(args.testdir / "apply_base_monkey.blend"), load_ui=False)
def test_subdividing_cube_results_in_same_mesh(self):
bpy.ops.mesh.primitive_monkey_add()
new_cube = bpy.context.object
multires_mod = new_cube.modifiers.new("Multires", 'MULTIRES')
bpy.ops.object.multires_subdivide(modifier="Multires")
bpy.ops.object.multires_base_apply(modifier="Multires")
bpy.ops.object.modifier_remove(modifier="Multires")
expected_mesh = bpy.data.objects['Expected_Base_Mesh']
result = expected_mesh.data.unit_test_compare(mesh=new_cube.data)
self.assertEqual(result, 'Same')
def main():
global args
import argparse
argv = [sys.argv[0]]
if '--' in sys.argv:
argv += sys.argv[sys.argv.index('--') + 1:]
parser = argparse.ArgumentParser()
parser.add_argument('--testdir', required=True, type=pathlib.Path)
args, remaining = parser.parse_known_args(argv)
unittest.main(argv=remaining)
if __name__ == '__main__':
main()