diff --git a/tests/components/trace/test_websocket_api.py b/tests/components/trace/test_websocket_api.py index 16c5304327a..38c6a0f097e 100644 --- a/tests/components/trace/test_websocket_api.py +++ b/tests/components/trace/test_websocket_api.py @@ -552,14 +552,24 @@ async def test_nested_traces(hass, hass_ws_client, domain, prefix): await hass.async_block_till_done() # List traces - await client.send_json({"id": next_id(), "type": "trace/list"}) + await client.send_json({"id": next_id(), "type": "trace/list", "domain": "script"}) response = await client.receive_json() assert response["success"] - assert len(response["result"]) == 2 - assert len(_find_traces(response["result"], domain, "sun")) == 1 + if domain == "automation": + assert len(response["result"]) == 1 + else: + assert len(response["result"]) == 2 assert len(_find_traces(response["result"], "script", "moon")) == 1 - sun_run_id = _find_run_id(response["result"], domain, "sun") moon_run_id = _find_run_id(response["result"], "script", "moon") + if domain == "automation": + await client.send_json( + {"id": next_id(), "type": "trace/list", "domain": "automation"} + ) + response = await client.receive_json() + assert response["success"] + assert len(response["result"]) == 1 + assert len(_find_traces(response["result"], domain, "sun")) == 1 + sun_run_id = _find_run_id(response["result"], domain, "sun") assert sun_run_id != moon_run_id # Get trace diff --git a/tests/helpers/test_condition.py b/tests/helpers/test_condition.py index 7c32f2c1192..05f348ddfeb 100644 --- a/tests/helpers/test_condition.py +++ b/tests/helpers/test_condition.py @@ -31,6 +31,12 @@ def assert_element(trace_element, expected_element, path): assert trace_element._error is None +@pytest.fixture(autouse=True) +def prepare_condition_trace(): + """Clear previous trace.""" + trace.trace_clear() + + def assert_condition_trace(expected): """Assert a trace condition sequence is as expected.""" condition_trace = trace.trace_get(clear=False)