Add type hints to core tests (#88478)
This commit is contained in:
@@ -15,7 +15,7 @@ def mock_collector():
|
||||
return collector
|
||||
|
||||
|
||||
def test_child_import(mock_collector):
|
||||
def test_child_import(mock_collector) -> None:
|
||||
"""Test detecting a child_import reference."""
|
||||
mock_collector.visit(
|
||||
ast.parse(
|
||||
@@ -27,7 +27,7 @@ from homeassistant.components import child_import
|
||||
assert mock_collector.unfiltered_referenced == {"child_import"}
|
||||
|
||||
|
||||
def test_subimport(mock_collector):
|
||||
def test_subimport(mock_collector) -> None:
|
||||
"""Test detecting a subimport reference."""
|
||||
mock_collector.visit(
|
||||
ast.parse(
|
||||
@@ -39,7 +39,7 @@ from homeassistant.components.subimport.smart_home import EVENT_ALEXA_SMART_HOME
|
||||
assert mock_collector.unfiltered_referenced == {"subimport"}
|
||||
|
||||
|
||||
def test_child_import_field(mock_collector):
|
||||
def test_child_import_field(mock_collector) -> None:
|
||||
"""Test detecting a child_import_field reference."""
|
||||
mock_collector.visit(
|
||||
ast.parse(
|
||||
@@ -51,7 +51,7 @@ from homeassistant.components.child_import_field import bla
|
||||
assert mock_collector.unfiltered_referenced == {"child_import_field"}
|
||||
|
||||
|
||||
def test_renamed_absolute(mock_collector):
|
||||
def test_renamed_absolute(mock_collector) -> None:
|
||||
"""Test detecting a renamed_absolute reference."""
|
||||
mock_collector.visit(
|
||||
ast.parse(
|
||||
@@ -63,7 +63,7 @@ import homeassistant.components.renamed_absolute as hue
|
||||
assert mock_collector.unfiltered_referenced == {"renamed_absolute"}
|
||||
|
||||
|
||||
def test_hass_components_var(mock_collector):
|
||||
def test_hass_components_var(mock_collector) -> None:
|
||||
"""Test detecting a hass_components_var reference."""
|
||||
mock_collector.visit(
|
||||
ast.parse(
|
||||
@@ -76,7 +76,7 @@ def bla(hass):
|
||||
assert mock_collector.unfiltered_referenced == {"hass_components_var"}
|
||||
|
||||
|
||||
def test_hass_components_class(mock_collector):
|
||||
def test_hass_components_class(mock_collector) -> None:
|
||||
"""Test detecting a hass_components_class reference."""
|
||||
mock_collector.visit(
|
||||
ast.parse(
|
||||
@@ -90,7 +90,7 @@ class Hello:
|
||||
assert mock_collector.unfiltered_referenced == {"hass_components_class"}
|
||||
|
||||
|
||||
def test_all_imports(mock_collector):
|
||||
def test_all_imports(mock_collector) -> None:
|
||||
"""Test all imports together."""
|
||||
mock_collector.visit(
|
||||
ast.parse(
|
||||
|
||||
@@ -23,7 +23,7 @@ def integration():
|
||||
return integration
|
||||
|
||||
|
||||
def test_validate_requirements_format_with_space(integration: Integration):
|
||||
def test_validate_requirements_format_with_space(integration: Integration) -> None:
|
||||
"""Test validate requirement with space around separator."""
|
||||
integration.manifest["requirements"] = ["test_package == 1"]
|
||||
assert not validate_requirements_format(integration)
|
||||
@@ -33,7 +33,7 @@ def test_validate_requirements_format_with_space(integration: Integration):
|
||||
]
|
||||
|
||||
|
||||
def test_validate_requirements_format_wrongly_pinned(integration: Integration):
|
||||
def test_validate_requirements_format_wrongly_pinned(integration: Integration) -> None:
|
||||
"""Test requirement with loose pin."""
|
||||
integration.manifest["requirements"] = ["test_package>=1"]
|
||||
assert not validate_requirements_format(integration)
|
||||
@@ -43,7 +43,9 @@ def test_validate_requirements_format_wrongly_pinned(integration: Integration):
|
||||
]
|
||||
|
||||
|
||||
def test_validate_requirements_format_ignore_pin_for_custom(integration: Integration):
|
||||
def test_validate_requirements_format_ignore_pin_for_custom(
|
||||
integration: Integration,
|
||||
) -> None:
|
||||
"""Test requirement ignore pinning for custom."""
|
||||
integration.manifest["requirements"] = [
|
||||
"test_package>=1",
|
||||
@@ -59,7 +61,7 @@ def test_validate_requirements_format_ignore_pin_for_custom(integration: Integra
|
||||
assert len(integration.errors) == 0
|
||||
|
||||
|
||||
def test_validate_requirements_format_invalid_version(integration: Integration):
|
||||
def test_validate_requirements_format_invalid_version(integration: Integration) -> None:
|
||||
"""Test requirement with invalid version."""
|
||||
integration.manifest["requirements"] = ["test_package==invalid"]
|
||||
assert not validate_requirements_format(integration)
|
||||
@@ -69,7 +71,7 @@ def test_validate_requirements_format_invalid_version(integration: Integration):
|
||||
]
|
||||
|
||||
|
||||
def test_validate_requirements_format_successful(integration: Integration):
|
||||
def test_validate_requirements_format_successful(integration: Integration) -> None:
|
||||
"""Test requirement with successful result."""
|
||||
integration.manifest["requirements"] = [
|
||||
"test_package==1.2.3",
|
||||
|
||||
@@ -22,7 +22,7 @@ def integration():
|
||||
return integration
|
||||
|
||||
|
||||
def test_validate_version_no_key(integration: Integration):
|
||||
def test_validate_version_no_key(integration: Integration) -> None:
|
||||
"""Test validate version with no key."""
|
||||
validate_version(integration)
|
||||
assert "No 'version' key in the manifest file." in [
|
||||
@@ -30,7 +30,7 @@ def test_validate_version_no_key(integration: Integration):
|
||||
]
|
||||
|
||||
|
||||
def test_validate_custom_integration_manifest(integration: Integration):
|
||||
def test_validate_custom_integration_manifest(integration: Integration) -> None:
|
||||
"""Test validate custom integration manifest."""
|
||||
|
||||
with pytest.raises(vol.Invalid):
|
||||
|
||||
Reference in New Issue
Block a user