mirror of
https://github.com/home-assistant/core.git
synced 2025-07-30 00:27:19 +00:00
Improve tests
This commit is contained in:
parent
a6a39103d7
commit
d7fc282d87
@ -641,6 +641,14 @@ def test_enum_with_deprecated_members_integration_not_found(
|
|||||||
assert len(caplog.record_tuples) == 0
|
assert len(caplog.record_tuples) == 0
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"positional_arguments",
|
||||||
|
[
|
||||||
|
[],
|
||||||
|
["first_arg"],
|
||||||
|
["first_arg", "second_arg"],
|
||||||
|
],
|
||||||
|
)
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("breaks_in_ha_version", "extra_msg"),
|
("breaks_in_ha_version", "extra_msg"),
|
||||||
[
|
[
|
||||||
@ -651,6 +659,7 @@ def test_enum_with_deprecated_members_integration_not_found(
|
|||||||
def test_deprecated_hass_binding(
|
def test_deprecated_hass_binding(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
positional_arguments: list[str],
|
||||||
breaks_in_ha_version: str | None,
|
breaks_in_ha_version: str | None,
|
||||||
extra_msg: str,
|
extra_msg: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -659,10 +668,10 @@ def test_deprecated_hass_binding(
|
|||||||
calls = []
|
calls = []
|
||||||
|
|
||||||
@deprecated_hass_binding(breaks_in_ha_version=breaks_in_ha_version)
|
@deprecated_hass_binding(breaks_in_ha_version=breaks_in_ha_version)
|
||||||
def mock_deprecated_function():
|
def mock_deprecated_function(*args: str) -> None:
|
||||||
calls.append("called")
|
calls.append(args)
|
||||||
|
|
||||||
mock_deprecated_function()
|
mock_deprecated_function(*positional_arguments)
|
||||||
assert (
|
assert (
|
||||||
"The deprecated argument hass was passed to mock_deprecated_function."
|
"The deprecated argument hass was passed to mock_deprecated_function."
|
||||||
f"{extra_msg}"
|
f"{extra_msg}"
|
||||||
@ -670,10 +679,14 @@ def test_deprecated_hass_binding(
|
|||||||
) not in caplog.text
|
) not in caplog.text
|
||||||
assert len(calls) == 1
|
assert len(calls) == 1
|
||||||
|
|
||||||
mock_deprecated_function(hass)
|
mock_deprecated_function(hass, *positional_arguments)
|
||||||
assert (
|
assert (
|
||||||
"The deprecated argument hass was passed to mock_deprecated_function."
|
"The deprecated argument hass was passed to mock_deprecated_function."
|
||||||
f"{extra_msg}"
|
f"{extra_msg}"
|
||||||
" Use mock_deprecated_function without hass argument instead"
|
" Use mock_deprecated_function without hass argument instead"
|
||||||
) in caplog.text
|
) in caplog.text
|
||||||
assert len(calls) == 2
|
assert len(calls) == 2
|
||||||
|
|
||||||
|
# Ensure that the two calls are the same, as the second call should have been
|
||||||
|
# modified to remove the hass argument.
|
||||||
|
assert calls[0] == calls[1]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user