mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Fail tests which JSON serialize mocks (#144261)
* Fail tests which JSON serialize mocks * Patch JSON helper earlier * Check type instead of attribute
This commit is contained in:
@@ -42,11 +42,14 @@ import respx
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
from syrupy.session import SnapshotSession
|
||||
|
||||
# Setup patching of JSON functions before any other Home Assistant imports
|
||||
from . import patch_json # isort:skip
|
||||
|
||||
from homeassistant import block_async_io
|
||||
from homeassistant.exceptions import ServiceNotFound
|
||||
|
||||
# Setup patching of recorder functions before any other Home Assistant imports
|
||||
from . import patch_recorder
|
||||
from . import patch_recorder # isort:skip
|
||||
|
||||
# Setup patching of dt_util time functions before any other Home Assistant imports
|
||||
from . import patch_time # noqa: F401, isort:skip
|
||||
@@ -449,6 +452,12 @@ def reset_globals() -> Generator[None]:
|
||||
frame.async_setup(None)
|
||||
frame._REPORTED_INTEGRATIONS.clear()
|
||||
|
||||
# Reset patch_json
|
||||
if patch_json.mock_objects:
|
||||
obj = patch_json.mock_objects.pop()
|
||||
patch_json.mock_objects.clear()
|
||||
pytest.fail(f"Test attempted to serialize mock object {obj}")
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope="session")
|
||||
def bcrypt_cost() -> Generator[None]:
|
||||
|
||||
Reference in New Issue
Block a user