test(execute): stop freeze capability flags leaking between test scenarios - #4692
Merged
Merged
Conversation
…arios fetch_inverter_data() narrows set_charge_freeze/set_export_freeze/ set_export_freeze_only when an inverter doesn't support freeze, and never widens them back. In production that's fine - fetch_config_options() re-derives them from raw config every cycle before fetch_inverter_data() runs, so a narrowing lasts exactly one cycle. run_execute_test() calls fetch_inverter_data() directly and is reused across many scenarios in one process, so the narrowing persisted for the rest of the run instead: a single scenario using a freeze-unsupported inverter would silently disable freeze in every later scenario, making results depend on test ordering. Re-derive all three from config in the helper, and add a regression test that runs a freeze-unsupported scenario followed by a supported one and asserts the flags survive. Verified the test fails without the fix (set_charge_freeze stuck at False) and passes with it. No production code change. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test-isolation bug found while reworking #4435 - independent of that ticket, so raising separately.
fetch_inverter_data()narrowsset_charge_freeze/set_export_freeze/set_export_freeze_onlywhen an inverter doesn't support freeze (execute.py:913-921), and never widens them back. In production that's correct:fetch_config_options()re-derives them from raw config every cycle beforefetch_inverter_data()runs, so a narrowing lasts exactly one cycle.run_execute_test()callsfetch_inverter_data()directly and is reused across many scenarios in a single process, so nothing re-derives them there. A single scenario using a freeze-unsupported inverter would silently disable freeze for every later scenario in the run - making test results depend on ordering.Nothing in the suite currently trips it, so this is preventive rather than a fix to a visibly-failing test - but it's a live trap for anyone adding a freeze-capability scenario later.
Changes
run_execute_test()before callingfetch_inverter_data().test_freeze_flags_do_not_leak_between_scenarios: runs a freeze-unsupported scenario, then a supported one, and asserts all three flags still match config.Test plan
set_charge_freeze leaked from the previous scenario - is False but config says True) and passes with it./run_all --test executepasses./run_pre_commitpasses (full suite, ruff, black, cspell, markdownlint)No production code change.
🤖 Generated with Claude Code