mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Fix import-outside-toplevel pylint warnings in core tests (#119394)
This commit is contained in:
parent
4bca0ad956
commit
fce4fc663e
@ -26,6 +26,7 @@ from aiohttp.test_utils import (
|
||||
)
|
||||
from aiohttp.typedefs import JSONDecoder
|
||||
from aiohttp.web import Application
|
||||
import bcrypt
|
||||
import freezegun
|
||||
import multidict
|
||||
import pytest
|
||||
@ -70,6 +71,7 @@ from homeassistant.helpers import (
|
||||
recorder as recorder_helper,
|
||||
)
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
from homeassistant.helpers.translation import _TranslationsCacheData
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.setup import BASE_PLATFORMS, async_setup_component
|
||||
from homeassistant.util import location
|
||||
@ -394,8 +396,6 @@ def reset_hass_threading_local_object() -> Generator[None]:
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def bcrypt_cost() -> Generator[None]:
|
||||
"""Run with reduced rounds during tests, to speed up uses."""
|
||||
import bcrypt
|
||||
|
||||
gensalt_orig = bcrypt.gensalt
|
||||
|
||||
def gensalt_mock(rounds=12, prefix=b"2b"):
|
||||
@ -1174,8 +1174,6 @@ def mock_get_source_ip() -> Generator[_patch]:
|
||||
@pytest.fixture(autouse=True, scope="session")
|
||||
def translations_once() -> Generator[_patch]:
|
||||
"""Only load translations once per session."""
|
||||
from homeassistant.helpers.translation import _TranslationsCacheData
|
||||
|
||||
cache = _TranslationsCacheData({}, {})
|
||||
patcher = patch(
|
||||
"homeassistant.helpers.translation._TranslationsCacheData",
|
||||
|
@ -36,6 +36,7 @@ async def test_extract_frame_resolve_module(
|
||||
hass: HomeAssistant, enable_custom_integrations
|
||||
) -> None:
|
||||
"""Test extracting the current frame from integration context."""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from custom_components.test_integration_frame import call_get_integration_frame
|
||||
|
||||
integration_frame = call_get_integration_frame()
|
||||
@ -53,6 +54,7 @@ async def test_get_integration_logger_resolve_module(
|
||||
hass: HomeAssistant, enable_custom_integrations
|
||||
) -> None:
|
||||
"""Test getting the logger from integration context."""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from custom_components.test_integration_frame import call_get_integration_logger
|
||||
|
||||
logger = call_get_integration_logger(__name__)
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from astral import LocationInfo
|
||||
import astral.sun
|
||||
from freezegun import freeze_time
|
||||
import pytest
|
||||
|
||||
@ -14,8 +16,6 @@ import homeassistant.util.dt as dt_util
|
||||
def test_next_events(hass: HomeAssistant) -> None:
|
||||
"""Test retrieving next sun events."""
|
||||
utc_now = datetime(2016, 11, 1, 8, 0, 0, tzinfo=dt_util.UTC)
|
||||
from astral import LocationInfo
|
||||
import astral.sun
|
||||
|
||||
utc_today = utc_now.date()
|
||||
|
||||
@ -89,8 +89,6 @@ def test_next_events(hass: HomeAssistant) -> None:
|
||||
def test_date_events(hass: HomeAssistant) -> None:
|
||||
"""Test retrieving next sun events."""
|
||||
utc_now = datetime(2016, 11, 1, 8, 0, 0, tzinfo=dt_util.UTC)
|
||||
from astral import LocationInfo
|
||||
import astral.sun
|
||||
|
||||
utc_today = utc_now.date()
|
||||
|
||||
@ -116,8 +114,6 @@ def test_date_events(hass: HomeAssistant) -> None:
|
||||
def test_date_events_default_date(hass: HomeAssistant) -> None:
|
||||
"""Test retrieving next sun events."""
|
||||
utc_now = datetime(2016, 11, 1, 8, 0, 0, tzinfo=dt_util.UTC)
|
||||
from astral import LocationInfo
|
||||
import astral.sun
|
||||
|
||||
utc_today = utc_now.date()
|
||||
|
||||
@ -144,8 +140,6 @@ def test_date_events_default_date(hass: HomeAssistant) -> None:
|
||||
def test_date_events_accepts_datetime(hass: HomeAssistant) -> None:
|
||||
"""Test retrieving next sun events."""
|
||||
utc_now = datetime(2016, 11, 1, 8, 0, 0, tzinfo=dt_util.UTC)
|
||||
from astral import LocationInfo
|
||||
import astral.sun
|
||||
|
||||
utc_today = utc_now.date()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user