From 67d9d771d04d51f5bd97f361ca1c15ae4a18c274 Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Fri, 6 Jan 2023 20:40:35 +0100 Subject: [PATCH] Fix tests when run on pytest 7.2, related to mark inheritance: https://github.com/pytest-dev/pytest/issues/7792 --- miio/integrations/airpurifier/zhimi/tests/test_airfresh.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/miio/integrations/airpurifier/zhimi/tests/test_airfresh.py b/miio/integrations/airpurifier/zhimi/tests/test_airfresh.py index ca5de6b43..33065a4ba 100644 --- a/miio/integrations/airpurifier/zhimi/tests/test_airfresh.py +++ b/miio/integrations/airpurifier/zhimi/tests/test_airfresh.py @@ -58,6 +58,11 @@ def __init__(self, *args, **kwargs): @pytest.fixture(scope="class") def airfresh(request): + # pytest 7.2.0 changed the handling of marks, see https://github.com/pytest-dev/pytest/issues/7792 + # the result is subclass device attribute to be overridden for TestAirFreshVA4, + # this hack checks if we already have a device to avoid doing that + if getattr(request.cls, "device", None) is not None: + return request.cls.device = DummyAirFresh() # TODO add ability to test on a real device