New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve tests of script trace #108717
Improve tests of script trace #108717
Conversation
tests/helpers/test_script.py
Outdated
if trace_element.path == "0": | ||
return | ||
if variables := expected_element.get("variables"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call trace_element.as_dict
instead and just do a simple equality assertion of the trace element dict under test and the expected element? Then just parametrize the expected element.
The current code is really hard to follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, or potentially even better, a custom syrupy serializer so we can just use snapshots.
Let's do that in a follow-up though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
1661332
to
49d8866
Compare
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Proposed change
Improve tests of script trace, without this PR we ignore variables in the trace of the first action
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: