Anim: Unit tests for "Insert Needed" #116419

Merged
Christoph Lendenfeld merged 4 commits from ChrisLend/blender:unit_tests_insert_needed into main 2024-01-05 09:52:31 +01:00

Add unit tests for the user preference option "Insert Needed"

Basic tests for objects and bones that check if autokeying in
combination with "Insert Needed" only

  • keys all location channels on the first key
  • keys only the modified channel on the second key

It is supposed to add only keyframes that have been affected
by the used transform operation.
E.g. translating an object will only add keys on translation keys.

The behavior of keying all property array channels first, and then
only add keys on values that have actually changed may change
in the future. Ideally it would only key actual changes to begin
with. But there is no way to do this right now.

Add unit tests for the user preference option "Insert Needed" Basic tests for objects and bones that check if autokeying in combination with "Insert Needed" only * keys all location channels on the first key * keys only the modified channel on the second key It is supposed to add only keyframes that have been affected by the used transform operation. E.g. translating an object will only add keys on translation keys. The behavior of keying all property array channels first, and then only add keys on values that have actually changed may change in the future. Ideally it would only key actual changes to begin with. But there is no way to do this right now.
Christoph Lendenfeld added the
Module
Animation & Rigging
label 2023-12-21 12:13:25 +01:00
Christoph Lendenfeld added 1 commit 2023-12-21 12:13:36 +01:00
Sybren A. Stüvel requested changes 2023-12-21 12:24:06 +01:00
@ -398,0 +420,4 @@
"location": (2, 1, 1)
}
for fcurve in action.fcurves:

This should check that len(expected_keys) == len(action.fcurves). Otherwise the test will succeed when there are no FCurves at all. In other words, the current test doesn't detect missing FCurves, it just detects unexpected ones.

This should check that `len(expected_keys) == len(action.fcurves)`. Otherwise the test will succeed when there are no FCurves at all. In other words, the current test doesn't detect missing FCurves, it just detects unexpected ones.
Author
Member

explicitly checking for 3 F-Curves self.assertEqual(len(action.fcurves), 3)

explicitly checking for 3 F-Curves `self.assertEqual(len(action.fcurves), 3)`

Yeah, my code wouldn't work well ;-) But you got the point of it!

Yeah, my code wouldn't work well ;-) But you got the point of it!
@ -398,0 +425,4 @@
raise AssertionError(f"Did not expect a key on {fcurve.data_path}")
self.assertEqual(expected_keys[fcurve.data_path][fcurve.array_index], len(fcurve.keyframe_points))
bpy.data.objects.remove(keyed_object, do_unlink=True)

This seems to be a teardown, basically to prevent this test from influencing the next one. This should be done in a teardown function (docs), so that it's ensured to be run even when the test itself fails.

This seems to be a teardown, basically to prevent this test from influencing the next one. This should be done in a teardown function ([docs](https://docs.python.org/3/library/unittest.html#unittest.TestCase.tearDown)), so that it's ensured to be run even when the test itself fails.
Author
Member

thanks, did not know that was a thing. Also made an override to the setUp function so it is a bit clearer which user prefs are set

I will check the other tests to see if they can be refactored with setUp and tearDown. Different PR though

thanks, did not know that was a thing. Also made an override to the `setUp` function so it is a bit clearer which user prefs are set I will check the other tests to see if they can be refactored with `setUp` and `tearDown`. Different PR though

The bpy.data.objects.remove(keyed_object, do_unlink=True) call also should be in the teardown though, otherwise the object will stay there when the test fails.

The `bpy.data.objects.remove(keyed_object, do_unlink=True)` call also should be in the teardown though, otherwise the object will stay there when the test fails.
Author
Member

I don't think this is an issue because the base class AbstractKeyframingTest has the setUp function:

def setUp(self):
    super().setUp()
    bpy.ops.wm.read_homefile(use_factory_startup=True)
I don't think this is an issue because the base class `AbstractKeyframingTest` has the `setUp` function: ``` def setUp(self): super().setUp() bpy.ops.wm.read_homefile(use_factory_startup=True) ```

In that case the object removal code can be removed altogether -- either it's worth calling (and thus ensuring it gets called), or it's worth removing. When in doubt, throw it into the canal!

In that case the object removal code can be removed altogether -- either it's worth calling (and thus ensuring it gets called), or it's worth removing. When in doubt, throw it into the canal!
Author
Member

threw it into the canal. Will do the same with the other tests in an upcoming refactor PR

threw it into the canal. Will do the same with the other tests in an upcoming refactor PR
Christoph Lendenfeld added 1 commit 2023-12-21 12:36:07 +01:00
Christoph Lendenfeld requested review from Sybren A. Stüvel 2023-12-21 12:38:19 +01:00
Sybren A. Stüvel requested changes 2023-12-21 15:36:45 +01:00
Sybren A. Stüvel left a comment
Member

Just one last move to setup/teardown.

Just one last move to setup/teardown.
Christoph Lendenfeld added 1 commit 2023-12-21 16:22:56 +01:00
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
a936d5653c
remove object deletion
Christoph Lendenfeld requested review from Sybren A. Stüvel 2024-01-04 11:30:10 +01:00
Sybren A. Stüvel approved these changes 2024-01-04 16:09:44 +01:00
Sybren A. Stüvel left a comment
Member

LGTM!

LGTM!
Author
Member

@blender-bot build

just running a sanity check build before adding new unit tests, even though they ran locally

@blender-bot build just running a sanity check build before adding new unit tests, even though they ran locally
Christoph Lendenfeld added 1 commit 2024-01-05 09:13:46 +01:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
885b47e0cb
Merge branch 'main' into unit_tests_insert_needed
Author
Member

@blender-bot build

all the tests failed to compile for various reasons. trying again

@blender-bot build all the tests failed to compile for various reasons. trying again
Christoph Lendenfeld merged commit 03a66af318 into main 2024-01-05 09:52:31 +01:00
Christoph Lendenfeld deleted branch unit_tests_insert_needed 2024-01-05 09:52:33 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
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
EEVEE & Viewport
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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
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
EEVEE & Viewport
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
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
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
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#116419
No description provided.