Anim: Unit Tests for "Insert Available" #116327

Merged
Christoph Lendenfeld merged 2 commits from ChrisLend/blender:tests_keyingsets into main 2023-12-21 10:22:29 +01:00

In preparation to the upcoming refactor of the keying set code,
extend the unit tests with more sophisticated
tests for "Insert Available".

This PR tests

  • key available using the preference setting with autokeying on an object and a bone
  • key available using the keyingset "Available"
In preparation to the upcoming refactor of the keying set code, extend the unit tests with more sophisticated tests for "Insert Available". This PR tests * key available using the preference setting with autokeying on an object and a bone * key available using the keyingset "Available"
Christoph Lendenfeld added the
Module
Animation & Rigging
label 2023-12-19 11:01:33 +01:00
Christoph Lendenfeld added 1 commit 2023-12-19 11:01:42 +01:00
Christoph Lendenfeld requested review from Sybren A. Stüvel 2023-12-19 13:22:57 +01:00
Sybren A. Stüvel requested changes 2023-12-19 14:29:19 +01:00
@ -319,0 +303,4 @@
bpy.context.scene.tool_settings.use_keyframe_insert_auto = True
bpy.context.preferences.edit.use_keyframe_insert_available = True
with bpy.context.temp_override(**_get_view3d_context()):

It would be nice if this could use something like:

with override_view3d_context():
    ...

Probably not for this PR, though ;-)

It would be nice if this could use something like: ```python with override_view3d_context(): ... ``` Probably not for this PR, though ;-)
Author
Member

is this a function that exists in bpy or would I have to create that?

is this a function that exists in bpy or would I have to create that?

I don't think it's there, it would just be:

def override_view3d_context():
    return bpy.context.temp_override(**_get_view3d_context())

At least I think that would work. If not Python is stupid and this can be ignored ;-)

I don't think it's there, it would just be: ```py def override_view3d_context(): return bpy.context.temp_override(**_get_view3d_context()) ``` At least I *think* that would work. If not Python is stupid and this can be ignored ;-)
@ -319,0 +324,4 @@
for fcurve in action.fcurves:
if "location" in fcurve.data_path:
self.assertEqual(len(fcurve.keyframe_points), 2)

Is the distinction between the 'rotation' and 'location' cases relevant here? Or could these two cases be merged with if any(substring in fcurve.data_path for substring in {'location', 'rotation'}) (or a more boring "location" in fcurve.data_path or "rotation" in fcurve.data_path)?

(same for the identical construct below)

Is the distinction between the 'rotation' and 'location' cases relevant here? Or could these two cases be merged with `if any(substring in fcurve.data_path for substring in {'location', 'rotation'})` (or a more boring `"location" in fcurve.data_path or "rotation" in fcurve.data_path`)? (same for the identical construct below)
Author
Member

did the boring way, I find that easier to read

did the boring way, I find that easier to read
@ -319,0 +326,4 @@
if "location" in fcurve.data_path:
self.assertEqual(len(fcurve.keyframe_points), 2)
elif "rotation" in fcurve.data_path:
# Moving the bone would also add rotation keys as long as "Only Insert Needed" is off.

Avoid the word "moving" in situations where there's a distinction between "translating" and "rotating". If this ambiguity is intentional, I'd write something like "Any transformation of the bone would ..."

Avoid the word "moving" in situations where there's a distinction between "translating" and "rotating". If this ambiguity is intentional, I'd write something like "Any transformation of the bone would ..."
dr.sybren marked this conversation as resolved
@ -319,0 +329,4 @@
# Moving the bone would also add rotation keys as long as "Only Insert Needed" is off.
self.assertEqual(len(fcurve.keyframe_points), 2)
else:
raise AssertionError("Did not expect keys other than location and rotation")

Include the data_path in this error, to help debug the situation when it occurs.

Include the data_path in this error, to help debug the situation when it occurs.
@ -319,0 +381,4 @@
with bpy.context.temp_override(**_get_view3d_context()):
self.assertRaises(RuntimeError, bpy.ops.anim.keyframe_insert_by_name, type="Available")
self.assertTrue(keyed_object.animation_data is None)

Use assertIsNone (docs).

Use `assertIsNone` ([docs](https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertIsNone)).
dr.sybren marked this conversation as resolved
Christoph Lendenfeld added 1 commit 2023-12-19 14:43:23 +01:00
Christoph Lendenfeld requested review from Sybren A. Stüvel 2023-12-19 14:43:23 +01:00
Sybren A. Stüvel approved these changes 2023-12-19 17:57:22 +01:00
Christoph Lendenfeld merged commit de61ec3e6f into main 2023-12-21 10:22:29 +01:00
Christoph Lendenfeld deleted branch tests_keyingsets 2023-12-21 10:22:31 +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#116327
No description provided.