diff --git a/tests/python/bl_animation_keyframing.py b/tests/python/bl_animation_keyframing.py index 884a9c375bd..9d88fc11015 100644 --- a/tests/python/bl_animation_keyframing.py +++ b/tests/python/bl_animation_keyframing.py @@ -202,31 +202,22 @@ class InsertKeyTest(AbstractKeyframingTest, unittest.TestCase): self.assertTrue(fcurve.keyframe_points[1].select_control_point) def test_keyframe_insert_py_func(self): - # Create a Bézier curve. - curve_data = bpy.data.curves.new("Curve", 'CURVE') - spline = curve_data.splines.new('BEZIER') - spline.bezier_points.add(2) - spline.bezier_points[0].co = (-1, 0, 0) - spline.bezier_points[1].co = (1, 0, 0) + curve_object = _create_animation_object() - curve_object = bpy.data.objects.new("Curve", curve_data) - bpy.context.scene.collection.objects.link(curve_object) - - # Test on ID sub-data. - # self.assertTrue(curve_data.splines[0].bezier_points[0].keyframe_insert('co')) - - # cu_fcurves = curve_data.animation_data.action.fcurves - - # self.assertEqual(len(cu_fcurves), 3, - # "Keying 'location' without any array index should have created 3 F-Curves") - # self.assertEqual(3 * ['splines[0].bezier_points[0].co'], [fcurve.data_path for fcurve in cu_fcurves]) - # self.assertEqual([0, 1, 2], [fcurve.array_index for fcurve in cu_fcurves]) - - # Test on the Object directly. - self.assertTrue(curve_object.keyframe_insert('rotation_quaternion', index=-1)) + # Test on location, which is a 3-item array, without explicitly passing an array index. + self.assertTrue(curve_object.keyframe_insert('location')) ob_fcurves = curve_object.animation_data.action.fcurves + self.assertEqual(len(ob_fcurves), 3, + "Keying 'location' without any array index should have created 3 F-Curves") + self.assertEqual(3 * ['location'], [fcurve.data_path for fcurve in ob_fcurves]) + self.assertEqual([0, 1, 2], [fcurve.array_index for fcurve in ob_fcurves]) + + ob_fcurves.clear() + + # Test on 'rotation_quaterion' (4 items), with explicit index=-1. + self.assertTrue(curve_object.keyframe_insert('rotation_quaternion', index=-1)) self.assertEqual(len(ob_fcurves), 4, "Keying 'rotation_quaternion' with index=-1 should have created 4 F-Curves") self.assertEqual(4 * ['rotation_quaternion'], [fcurve.data_path for fcurve in ob_fcurves]) @@ -234,6 +225,7 @@ class InsertKeyTest(AbstractKeyframingTest, unittest.TestCase): ob_fcurves.clear() + # Test on 'scale' (3 items) with explicit index=1. self.assertTrue(curve_object.keyframe_insert('scale', index=2)) self.assertEqual(len(ob_fcurves), 1, "Keying 'scale' with index=2 should have created 1 F-Curve")