Skip to content

Commit e771487

Browse files
committed
Fixed test setup
1 parent 9fb5f4a commit e771487

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

tests/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from custom_components.sunspec.api import ConnectionError
1313
from custom_components.sunspec.api import ConnectionTimeoutError
14+
from custom_components.sunspec.api import SunSpecApiClient
1415

1516
pytest_plugins = "pytest_homeassistant_custom_component"
1617
_LOGGER: logging.Logger = logging.getLogger(__package__)
@@ -58,6 +59,14 @@ def auto_enable_custom_integrations(
5859
"""Enable custom integrations defined in the test dir."""
5960

6061

62+
@pytest.fixture(autouse=True)
63+
def clear_sunspec_client_cache():
64+
"""Avoid cross-test reuse of cached clients with different fixture behavior."""
65+
SunSpecApiClient.CLIENT_CACHE = {}
66+
yield
67+
SunSpecApiClient.CLIENT_CACHE = {}
68+
69+
6170
# This fixture, when used, will result in calls to async_get_data to return None. To have the call
6271
# return a value, we would add the `return_value=<VALUE_TO_RETURN>` parameter to the patch call.
6372
@pytest.fixture(name="bypass_get_device_info")

0 commit comments

Comments
 (0)