Skip to content

Commit daa3caf

Browse files
test(config): restore every setting after the config JSON round-trip test
load_current_config() rewrites every saved CONFIG_ITEMS value on the shared PredBat fixture, but the test only put load_scaling back. Any value that does not survive a JSON round-trip unchanged (a tuple read back as a list, for example) would then leak into later tests, the order-dependent pollution seen in #5079. Snapshot all values before the save and restore them in the finally block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent f048e86 commit daa3caf

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎apps/predbat/tests/test_config_json_format.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def test_config_json_format(my_predbat):
2626
original_config_root_p = my_predbat.config_root_p
2727
original_db_primary = my_predbat.ha_interface.db_primary
2828
item = my_predbat.config_index["load_scaling"]
29-
original_value = item["value"]
29+
# load_current_config() rewrites every saved setting on the shared fixture, so snapshot them all to put back afterwards
30+
original_values = {config_item["name"]: config_item.get("value", None) for config_item in my_predbat.CONFIG_ITEMS if "value" in config_item}
3031

3132
try:
3233
with tempfile.TemporaryDirectory() as tmp_root:
@@ -58,6 +59,8 @@ def test_config_json_format(my_predbat):
5859
my_predbat.config_root = original_config_root
5960
my_predbat.config_root_p = original_config_root_p
6061
my_predbat.ha_interface.db_primary = original_db_primary
61-
item["value"] = original_value
62+
for config_item in my_predbat.CONFIG_ITEMS:
63+
if config_item["name"] in original_values:
64+
config_item["value"] = original_values[config_item["name"]]
6265

6366
return failed

0 commit comments

Comments
 (0)