Improve number deprecation warnings (#73552)

This commit is contained in:
Erik Montnemery 2022-06-16 09:05:13 +02:00 committed by GitHub
parent af81ec1f5f
commit 2d07cda4e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 4 deletions

View file

@ -229,8 +229,8 @@ async def test_attributes(hass: HomeAssistant) -> None:
assert number_4.value is None
async def test_attributes_deprecated(hass: HomeAssistant, caplog) -> None:
"""Test overriding the deprecated attributes."""
async def test_deprecation_warnings(hass: HomeAssistant, caplog) -> None:
"""Test overriding the deprecated attributes is possible and warnings are logged."""
number = MockDefaultNumberEntityDeprecated()
number.hass = hass
assert number.max_value == 100.0
@ -263,6 +263,10 @@ async def test_attributes_deprecated(hass: HomeAssistant, caplog) -> None:
assert number_4.unit_of_measurement == "rabbits"
assert number_4.value == 0.5
assert (
"tests.components.number.test_init::MockNumberEntityDeprecated is overriding "
" deprecated methods on an instance of NumberEntity"
)
assert (
"Entity None (<class 'tests.components.number.test_init.MockNumberEntityAttrDeprecated'>) "
"is using deprecated NumberEntity features" in caplog.text