mirror of
https://github.com/esphome/esphome.git
synced 2026-08-22 22:26:21 +00:00
Pin sortedness on a nested fixture in the comment-order test
This commit is contained in:
@@ -7148,9 +7148,13 @@ async def test_wrap_to_code_comment_is_insertion_order_independent() -> None:
|
|||||||
comp = SimpleNamespace(to_code=to_code, config_schema=object())
|
comp = SimpleNamespace(to_code=to_code, config_schema=object())
|
||||||
wrapped = _wrap_to_code("demo", comp, yaml_util)
|
wrapped = _wrap_to_code("demo", comp, yaml_util)
|
||||||
with patch("esphome.codegen.add", side_effect=lambda st: comments.append(str(st))):
|
with patch("esphome.codegen.add", side_effect=lambda st: comments.append(str(st))):
|
||||||
await wrapped({"beta": 1, "alpha": 2})
|
# Nested on purpose: the real churn lives in nested action configs,
|
||||||
first = list(comments)
|
# so sorting must apply at every mapping level
|
||||||
|
await wrapped({"beta": 1, "alpha": {"z": 1, "a": 2}})
|
||||||
|
first = "\n".join(comments)
|
||||||
comments.clear()
|
comments.clear()
|
||||||
await wrapped({"alpha": 2, "beta": 1})
|
await wrapped({"alpha": {"a": 2, "z": 1}, "beta": 1})
|
||||||
assert first == comments
|
second = "\n".join(comments)
|
||||||
assert "alpha: 2" in comments[1]
|
assert first == second
|
||||||
|
assert second.index("alpha") < second.index("beta")
|
||||||
|
assert second.index("a: 2") < second.index("z: 1")
|
||||||
|
|||||||
Reference in New Issue
Block a user