Skip to content

Commit 10525e5

Browse files
fix(tests): restore predbat_created_entities in test_custom_type_respects_configured_time_entity
The test's finally block restored my_predbat.args but not my_predbat.predbat_created_entities, the registry create_entity() now writes dummy ids into (904253c). Since tests share one fixture, the dummy ids created here leaked into every later test in the run. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 904253c commit 10525e5

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎apps/predbat/tests/test_inverter.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ def test_custom_type_respects_configured_time_entity(my_predbat):
6363

6464
saved_args = copy.deepcopy(my_predbat.args)
6565
saved_def = copy.deepcopy(INVERTER_DEF.get("TEST_CUSTOM_TIME_ENTITY"))
66+
had_created_entities = hasattr(my_predbat, "predbat_created_entities")
67+
saved_created_entities = copy.deepcopy(my_predbat.predbat_created_entities) if had_created_entities else None
6668

6769
try:
6870
# Case 1: real entity configured - must be kept, not overwritten
@@ -163,6 +165,11 @@ def test_custom_type_respects_configured_time_entity(my_predbat):
163165
failed = True
164166
finally:
165167
my_predbat.args = saved_args
168+
if had_created_entities:
169+
my_predbat.predbat_created_entities = saved_created_entities
170+
else:
171+
if hasattr(my_predbat, "predbat_created_entities"):
172+
del my_predbat.predbat_created_entities
166173
if saved_def is None:
167174
INVERTER_DEF.pop("TEST_CUSTOM_TIME_ENTITY", None)
168175
else:

0 commit comments

Comments
 (0)