mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 02:49:40 +00:00
Remove deprecated json helper constants and function (#150111)
This commit is contained in:
@@ -13,7 +13,6 @@ from unittest.mock import Mock, patch
|
||||
import pytest
|
||||
|
||||
from homeassistant.core import Event, HomeAssistant, State
|
||||
from homeassistant.helpers import json as json_helper
|
||||
from homeassistant.helpers.json import (
|
||||
ExtendedJSONEncoder,
|
||||
JSONEncoder as DefaultHASSJSONEncoder,
|
||||
@@ -27,14 +26,9 @@ from homeassistant.helpers.json import (
|
||||
)
|
||||
from homeassistant.util import dt as dt_util
|
||||
from homeassistant.util.color import RGBColor
|
||||
from homeassistant.util.json import (
|
||||
JSON_DECODE_EXCEPTIONS,
|
||||
JSON_ENCODE_EXCEPTIONS,
|
||||
SerializationError,
|
||||
load_json,
|
||||
)
|
||||
from homeassistant.util.json import SerializationError, load_json
|
||||
|
||||
from tests.common import import_and_test_deprecated_constant, json_round_trip
|
||||
from tests.common import json_round_trip
|
||||
|
||||
# Test data that can be saved as JSON
|
||||
TEST_JSON_A = {"a": 1, "B": "two"}
|
||||
@@ -350,50 +344,3 @@ def test_find_unserializable_data() -> None:
|
||||
BadData(),
|
||||
dump=partial(json.dumps, cls=MockJSONEncoder),
|
||||
) == {"$(BadData).bla": bad_data}
|
||||
|
||||
|
||||
def test_deprecated_json_loads(caplog: pytest.LogCaptureFixture) -> None:
|
||||
"""Test deprecated json_loads function.
|
||||
|
||||
It was moved from helpers to util in #88099
|
||||
"""
|
||||
json_helper.json_loads("{}")
|
||||
assert (
|
||||
"The deprecated function json_loads was called. It will be removed "
|
||||
"in HA Core 2025.8. Use homeassistant.util.json.json_loads instead"
|
||||
) in caplog.text
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("constant_name", "replacement_name", "replacement"),
|
||||
[
|
||||
(
|
||||
"JSON_DECODE_EXCEPTIONS",
|
||||
"homeassistant.util.json.JSON_DECODE_EXCEPTIONS",
|
||||
JSON_DECODE_EXCEPTIONS,
|
||||
),
|
||||
(
|
||||
"JSON_ENCODE_EXCEPTIONS",
|
||||
"homeassistant.util.json.JSON_ENCODE_EXCEPTIONS",
|
||||
JSON_ENCODE_EXCEPTIONS,
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_deprecated_aliases(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
constant_name: str,
|
||||
replacement_name: str,
|
||||
replacement: Any,
|
||||
) -> None:
|
||||
"""Test deprecated JSON_DECODE_EXCEPTIONS and JSON_ENCODE_EXCEPTIONS constants.
|
||||
|
||||
They were moved from helpers to util in #88099
|
||||
"""
|
||||
import_and_test_deprecated_constant(
|
||||
caplog,
|
||||
json_helper,
|
||||
constant_name,
|
||||
replacement_name,
|
||||
replacement,
|
||||
"2025.8",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user