Add type hints to core tests (#88478)
This commit is contained in:
parent
26755a6841
commit
5f25b71df7
59 changed files with 1068 additions and 547 deletions
|
@ -174,7 +174,7 @@ def test_entity_id() -> None:
|
|||
|
||||
|
||||
@pytest.mark.parametrize("validator", [cv.entity_ids, cv.entity_ids_or_uuids])
|
||||
def test_entity_ids(validator):
|
||||
def test_entity_ids(validator) -> None:
|
||||
"""Test entity ID validation."""
|
||||
schema = vol.Schema(validator)
|
||||
|
||||
|
@ -751,7 +751,7 @@ def version(monkeypatch):
|
|||
monkeypatch.setattr(homeassistant.const, "__version__", "0.5.0")
|
||||
|
||||
|
||||
def test_deprecated_with_no_optionals(caplog, schema):
|
||||
def test_deprecated_with_no_optionals(caplog: pytest.LogCaptureFixture, schema) -> None:
|
||||
"""Test deprecation behaves correctly when optional params are None.
|
||||
|
||||
Expected behavior:
|
||||
|
@ -782,7 +782,9 @@ def test_deprecated_with_no_optionals(caplog, schema):
|
|||
assert test_data == output
|
||||
|
||||
|
||||
def test_deprecated_or_removed_param_and_raise(caplog, schema):
|
||||
def test_deprecated_or_removed_param_and_raise(
|
||||
caplog: pytest.LogCaptureFixture, schema
|
||||
) -> None:
|
||||
"""Test removed or deprecation options and fail the config validation by raising an exception.
|
||||
|
||||
Expected behavior:
|
||||
|
@ -821,7 +823,9 @@ def test_deprecated_or_removed_param_and_raise(caplog, schema):
|
|||
assert test_data == output
|
||||
|
||||
|
||||
def test_deprecated_with_replacement_key(caplog, schema):
|
||||
def test_deprecated_with_replacement_key(
|
||||
caplog: pytest.LogCaptureFixture, schema
|
||||
) -> None:
|
||||
"""Test deprecation behaves correctly when only a replacement key is provided.
|
||||
|
||||
Expected behavior:
|
||||
|
@ -858,7 +862,7 @@ def test_deprecated_with_replacement_key(caplog, schema):
|
|||
assert test_data == output
|
||||
|
||||
|
||||
def test_deprecated_with_default(caplog, schema):
|
||||
def test_deprecated_with_default(caplog: pytest.LogCaptureFixture, schema) -> None:
|
||||
"""Test deprecation behaves correctly with a default value.
|
||||
|
||||
This is likely a scenario that would never occur.
|
||||
|
@ -886,7 +890,9 @@ def test_deprecated_with_default(caplog, schema):
|
|||
assert test_data == output
|
||||
|
||||
|
||||
def test_deprecated_with_replacement_key_and_default(caplog, schema):
|
||||
def test_deprecated_with_replacement_key_and_default(
|
||||
caplog: pytest.LogCaptureFixture, schema
|
||||
) -> None:
|
||||
"""Test deprecation with a replacement key and default.
|
||||
|
||||
Expected behavior:
|
||||
|
@ -960,7 +966,9 @@ def test_deprecated_cant_find_module() -> None:
|
|||
)
|
||||
|
||||
|
||||
def test_deprecated_or_removed_logger_with_config_attributes(caplog):
|
||||
def test_deprecated_or_removed_logger_with_config_attributes(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test if the logger outputs the correct message if the line and file attribute is available in config."""
|
||||
file: str = "configuration.yaml"
|
||||
line: int = 54
|
||||
|
@ -997,7 +1005,9 @@ def test_deprecated_or_removed_logger_with_config_attributes(caplog):
|
|||
assert len(caplog.records) == 0
|
||||
|
||||
|
||||
def test_deprecated_logger_with_one_config_attribute(caplog):
|
||||
def test_deprecated_logger_with_one_config_attribute(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test if the logger outputs the correct message if only one of line and file attribute is available in config."""
|
||||
file: str = "configuration.yaml"
|
||||
line: int = 54
|
||||
|
@ -1031,7 +1041,9 @@ def test_deprecated_logger_with_one_config_attribute(caplog):
|
|||
assert len(caplog.records) == 0
|
||||
|
||||
|
||||
def test_deprecated_logger_without_config_attributes(caplog):
|
||||
def test_deprecated_logger_without_config_attributes(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test if the logger outputs the correct message if the line and file attribute is not available in config."""
|
||||
file: str = "configuration.yaml"
|
||||
line: int = 54
|
||||
|
@ -1166,7 +1178,7 @@ def test_comp_entity_ids() -> None:
|
|||
schema(invalid)
|
||||
|
||||
|
||||
def test_uuid4_hex(caplog):
|
||||
def test_uuid4_hex(caplog: pytest.LogCaptureFixture) -> None:
|
||||
"""Test uuid validation."""
|
||||
schema = vol.Schema(cv.uuid4_hex)
|
||||
|
||||
|
@ -1262,7 +1274,7 @@ def test_key_value_schemas_with_default() -> None:
|
|||
schema({"mode": "{{ 1 + 1}}"})
|
||||
|
||||
|
||||
def test_script(caplog):
|
||||
def test_script(caplog: pytest.LogCaptureFixture) -> None:
|
||||
"""Test script validation is user friendly."""
|
||||
for data, msg in (
|
||||
({"delay": "{{ invalid"}, "should be format 'HH:MM'"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue