Anim: Unit tests for inserting keyframes #114465
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#114465
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ChrisLend/blender:keyframing_unittests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Cover the current behavior of keyframe insertion with unit tests,
so the changes planned in #113278: Anim: Keyframing Rework are less likely to break things.
Unit tests added:
I'm not super familiar with the Python unit testing framework, but things basically look good to me. Just some minor comments.
@ -0,0 +14,4 @@
def _fcurve_paths_match(fcurves: list, expected_paths: list) -> bool:
data_paths = list(set([fcurve.data_path for fcurve in fcurves]))
I might be misunderstanding something, but the
list(set())
looks redundant to me. Can't it just be[fcurve.data_path for fcurve in fcurves]
stand-alone?the data_path for fcurves is e.g. "location"
so when you have fcurves on location x, y and z you would get "location" 3 times within data_paths
Ah, got it. Thanks for the explanation!
@ -0,0 +34,4 @@
def _insert_by_name_test(insert_key: str, expected_paths: list):
bpy.ops.mesh.primitive_monkey_add()
I don't feel strongly about this, so feel free to ignore if your disagree. But since we're not testing the the add object operator, I would prefer to add objects via the Python API rather than by operator, and explicitly link it to the scene collection and make it selected+active. It's more verbose, but doesn't rely on implicit side effects of operators.
And since you do this multiple times in the code, just making a function out of it would make sense. And then you can include setting the rotation mode as well.
that's a good point. will do
@ -0,0 +41,4 @@
with bpy.context.temp_override(**_get_view3d_context()):
bpy.ops.anim.keyframe_insert_by_name(type=insert_key)
match = _fcurve_paths_match(keyed_object.animation_data.action.fcurves, expected_paths)
bpy.ops.object.delete(use_global=False)
Similarly, I would prefer deleting the object via the Python API rather than by operator.
@ -0,0 +185,4 @@
self.assertEqual(len(fcurve.keyframe_points), 4)
for key in fcurve.keyframe_points:
# No keyframe should be outside the cyclic range.
self.assertLessEqual(key.co.x, cyclic_range_end)
I think it would be better to test for the exact frame values you expect here. Additionally, it might be good to add a key at a frame earlier than the action frame range to make sure that gets mapped back in properly as well.
Good point, done that :)
@ -0,0 +94,4 @@
def test_visual_location_keying_set(self):
t_value = 1
bpy.ops.object.empty_add(type="PLAIN_AXES", align="WORLD", location=(t_value, t_value, t_value))
Looks like there are still some left over operator-based object adds.
thanks, replaced those now with the same function call
Looks good to me!