From 31061b9f351c65b9cf3cdc96c6143e66a6889367 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sat, 18 Feb 2023 14:38:19 +0100 Subject: [PATCH] Fix snapshots testing repr 0 value IntFlags (#88379) --- tests/syrupy.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/syrupy.py b/tests/syrupy.py index ff3b0caa05a..346b15259eb 100644 --- a/tests/syrupy.py +++ b/tests/syrupy.py @@ -3,6 +3,7 @@ from __future__ import annotations from contextlib import suppress import dataclasses +from enum import IntFlag from pathlib import Path from typing import Any @@ -110,6 +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: + # 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 else: serializable_data = data with suppress(TypeError):