Remove assert_lists_same test helper (#94904)
This commit is contained in:
parent
05039036f1
commit
732ce34a66
4 changed files with 7 additions and 20 deletions
|
@ -1,5 +1,6 @@
|
||||||
"""The tests for NEW_NAME device actions."""
|
"""The tests for NEW_NAME device actions."""
|
||||||
import pytest
|
import pytest
|
||||||
|
from pytest_unordered import unordered
|
||||||
|
|
||||||
from homeassistant.components import automation
|
from homeassistant.components import automation
|
||||||
from homeassistant.components.device_automation import DeviceAutomationType
|
from homeassistant.components.device_automation import DeviceAutomationType
|
||||||
|
@ -11,7 +12,6 @@ from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
MockConfigEntry,
|
MockConfigEntry,
|
||||||
assert_lists_same,
|
|
||||||
async_get_device_automations,
|
async_get_device_automations,
|
||||||
async_mock_service,
|
async_mock_service,
|
||||||
)
|
)
|
||||||
|
@ -44,7 +44,7 @@ async def test_get_actions(
|
||||||
actions = await async_get_device_automations(
|
actions = await async_get_device_automations(
|
||||||
hass, DeviceAutomationType.ACTION, device_entry.id
|
hass, DeviceAutomationType.ACTION, device_entry.id
|
||||||
)
|
)
|
||||||
assert_lists_same(actions, expected_actions)
|
assert actions == unordered(expected_actions)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
@ -91,7 +91,7 @@ async def test_get_actions_hidden_auxiliary(
|
||||||
actions = await async_get_device_automations(
|
actions = await async_get_device_automations(
|
||||||
hass, DeviceAutomationType.ACTION, device_entry.id
|
hass, DeviceAutomationType.ACTION, device_entry.id
|
||||||
)
|
)
|
||||||
assert_lists_same(actions, expected_actions)
|
assert actions == unordered(expected_actions)
|
||||||
|
|
||||||
|
|
||||||
async def test_action(hass: HomeAssistant) -> None:
|
async def test_action(hass: HomeAssistant) -> None:
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from pytest_unordered import unordered
|
||||||
|
|
||||||
from homeassistant.components import automation
|
from homeassistant.components import automation
|
||||||
from homeassistant.components.device_automation import DeviceAutomationType
|
from homeassistant.components.device_automation import DeviceAutomationType
|
||||||
|
@ -13,7 +14,6 @@ from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
MockConfigEntry,
|
MockConfigEntry,
|
||||||
assert_lists_same,
|
|
||||||
async_get_device_automations,
|
async_get_device_automations,
|
||||||
async_mock_service,
|
async_mock_service,
|
||||||
)
|
)
|
||||||
|
@ -59,7 +59,7 @@ async def test_get_conditions(
|
||||||
conditions = await async_get_device_automations(
|
conditions = await async_get_device_automations(
|
||||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
)
|
)
|
||||||
assert_lists_same(conditions, expected_conditions)
|
assert conditions == unordered(expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
async def test_if_state(hass: HomeAssistant, calls: list[ServiceCall]) -> None:
|
async def test_if_state(hass: HomeAssistant, calls: list[ServiceCall]) -> None:
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""The tests for NEW_NAME device triggers."""
|
"""The tests for NEW_NAME device triggers."""
|
||||||
import pytest
|
import pytest
|
||||||
|
from pytest_unordered import unordered
|
||||||
|
|
||||||
from homeassistant.components import automation
|
from homeassistant.components import automation
|
||||||
from homeassistant.components.device_automation import DeviceAutomationType
|
from homeassistant.components.device_automation import DeviceAutomationType
|
||||||
|
@ -11,7 +12,6 @@ from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
MockConfigEntry,
|
MockConfigEntry,
|
||||||
assert_lists_same,
|
|
||||||
async_get_device_automations,
|
async_get_device_automations,
|
||||||
async_mock_service,
|
async_mock_service,
|
||||||
)
|
)
|
||||||
|
@ -57,7 +57,7 @@ async def test_get_triggers(
|
||||||
triggers = await async_get_device_automations(
|
triggers = await async_get_device_automations(
|
||||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||||
)
|
)
|
||||||
assert_lists_same(triggers, expected_triggers)
|
assert triggers == unordered(expected_triggers)
|
||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_state_change(
|
async def test_if_fires_on_state_change(
|
||||||
|
|
|
@ -1373,19 +1373,6 @@ def async_mock_signal(hass: HomeAssistant, signal: str) -> list[tuple[Any]]:
|
||||||
return calls
|
return calls
|
||||||
|
|
||||||
|
|
||||||
def assert_lists_same(a: list[Any], b: list[Any]) -> None:
|
|
||||||
"""Compare two lists, ignoring order.
|
|
||||||
|
|
||||||
Check both that all items in a are in b and that all items in b are in a,
|
|
||||||
otherwise assert_lists_same(["1", "1"], ["1", "2"]) could be True.
|
|
||||||
"""
|
|
||||||
assert len(a) == len(b)
|
|
||||||
for i in a:
|
|
||||||
assert i in b
|
|
||||||
for i in b:
|
|
||||||
assert i in a
|
|
||||||
|
|
||||||
|
|
||||||
_SENTINEL = object()
|
_SENTINEL = object()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue