mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Move common function for testing derepcation constants to util (#106063)
This commit is contained in:
parent
0e0fd39603
commit
c226d793d4
@ -1,7 +1,12 @@
|
||||
"""Test deprecated binary sensor device classes."""
|
||||
from functools import partial
|
||||
|
||||
from homeassistant.components import binary_sensor
|
||||
|
||||
from .util import import_and_test_deprecated_costant
|
||||
|
||||
def import_deprecated(device_class: binary_sensor.BinarySensorDeviceClass):
|
||||
"""Import deprecated device class constant."""
|
||||
getattr(binary_sensor, f"DEVICE_CLASS_{device_class.name}")
|
||||
import_deprecated = partial(
|
||||
import_and_test_deprecated_costant,
|
||||
module=binary_sensor,
|
||||
constant_prefix="DEVICE_CLASS_",
|
||||
)
|
||||
|
@ -0,0 +1,11 @@
|
||||
"""util module for test_constant_deprecation tests."""
|
||||
|
||||
from enum import Enum
|
||||
from types import ModuleType
|
||||
|
||||
|
||||
def import_and_test_deprecated_costant(
|
||||
replacement: Enum, module: ModuleType, constant_prefix: str
|
||||
) -> None:
|
||||
"""Import and test deprecated constant."""
|
||||
assert getattr(module, constant_prefix + replacement.name) == replacement
|
Loading…
x
Reference in New Issue
Block a user