mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Verify respx mock routes are cleaned up when tests finish (#122852)
This commit is contained in:
parent
4a34855a92
commit
6840f27bc6
@ -34,6 +34,7 @@ import multidict
|
|||||||
import pytest
|
import pytest
|
||||||
import pytest_socket
|
import pytest_socket
|
||||||
import requests_mock
|
import requests_mock
|
||||||
|
import respx
|
||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant import block_async_io
|
from homeassistant import block_async_io
|
||||||
@ -398,6 +399,13 @@ def verify_cleanup(
|
|||||||
# Restore the default time zone to not break subsequent tests
|
# Restore the default time zone to not break subsequent tests
|
||||||
dt_util.DEFAULT_TIME_ZONE = datetime.UTC
|
dt_util.DEFAULT_TIME_ZONE = datetime.UTC
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Verify respx.mock has been cleaned up
|
||||||
|
assert not respx.mock.routes, "respx.mock routes not cleaned up, maybe the test needs to be decorated with @respx.mock"
|
||||||
|
finally:
|
||||||
|
# Clear mock routes not break subsequent tests
|
||||||
|
respx.mock.clear()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def reset_hass_threading_local_object() -> Generator[None]:
|
def reset_hass_threading_local_object() -> Generator[None]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user