diff --git a/.core_files.yaml b/.core_files.yaml index 7bf7a09b36b..7933556b603 100644 --- a/.core_files.yaml +++ b/.core_files.yaml @@ -125,6 +125,7 @@ tests: &tests - tests/mock/** - tests/pylint/** - tests/scripts/** + - tests/syrupy.py - tests/test_util/** - tests/testing_config/** - tests/util/** diff --git a/tests/components/elgato/snapshots/test_light.ambr b/tests/components/elgato/snapshots/test_light.ambr index 53958516739..31f5dfba217 100644 --- a/tests/components/elgato/snapshots/test_light.ambr +++ b/tests/components/elgato/snapshots/test_light.ambr @@ -23,7 +23,7 @@ 'supported_color_modes': list([ , ]), - 'supported_features': 0, + 'supported_features': , 'xy_color': tuple( 0.465, 0.376, @@ -130,7 +130,7 @@ , , ]), - 'supported_features': 0, + 'supported_features': , 'xy_color': tuple( 0.465, 0.376, @@ -236,7 +236,7 @@ , , ]), - 'supported_features': 0, + 'supported_features': , 'xy_color': tuple( 0.34, 0.327, diff --git a/tests/syrupy.py b/tests/syrupy.py index 4f646a05eb6..f18c11bf5d5 100644 --- a/tests/syrupy.py +++ b/tests/syrupy.py @@ -111,10 +111,10 @@ class HomeAssistantSnapshotSerializer(AmberDataSerializer): serializable_data = cls._serializable_config_entry(data) elif dataclasses.is_dataclass(data): serializable_data = dataclasses.asdict(data) - elif isinstance(data, IntFlag) and data == 0: + elif isinstance(data, IntFlag): # The repr of an enum.IntFlag has changed between Python 3.10 and 3.11 - # This only concerns the 0 case, which we normalize here - serializable_data = 0 + # so we normalize it here. + serializable_data = _IntFlagWrapper(data) else: serializable_data = data with suppress(TypeError): @@ -201,6 +201,17 @@ class HomeAssistantSnapshotSerializer(AmberDataSerializer): ) +class _IntFlagWrapper: + def __init__(self, flag: IntFlag) -> None: + self._flag = flag + + def __repr__(self) -> str: + # 3.10: + # 3.11: + # Syrupy: + return f"<{self._flag.__class__.__name__}: {self._flag.value}>" + + class HomeAssistantSnapshotExtension(AmberSnapshotExtension): """Home Assistant extension for Syrupy."""