1
0
mirror of https://github.com/home-assistant/core.git synced 2026-02-15 07:36:16 +00:00

Update pytest-asyncio to 1.0.0 (#145988)

* Update pytest-asyncio to 1.0.0

* Remove event_loop fixture uses
This commit is contained in:
Marc Mueller
2025-06-02 06:12:22 +02:00
committed by GitHub
parent dd85a1e5f0
commit 5e377b89fc
11 changed files with 22 additions and 35 deletions

View File

@@ -1,7 +1,7 @@
"""Test the auth script to manage local users."""
import argparse
from asyncio import AbstractEventLoop
import asyncio
from collections.abc import Generator
import logging
from typing import Any
@@ -143,7 +143,7 @@ async def test_change_password_invalid_user(
data.validate_login("invalid-user", "new-pass")
def test_parsing_args(event_loop: AbstractEventLoop) -> None:
async def test_parsing_args() -> None:
"""Test we parse args correctly."""
called = False
@@ -158,7 +158,8 @@ def test_parsing_args(event_loop: AbstractEventLoop) -> None:
args = Mock(config="/somewhere/config", func=mock_func)
event_loop = asyncio.get_event_loop()
with patch("argparse.ArgumentParser.parse_args", return_value=args):
script_auth.run(None)
await event_loop.run_in_executor(None, script_auth.run, None)
assert called, "Mock function did not get called"

View File

@@ -55,7 +55,7 @@ def normalize_yaml_files(check_dict):
@pytest.mark.parametrize("hass_config_yaml", [BAD_CORE_CONFIG])
@pytest.mark.usefixtures("mock_is_file", "event_loop", "mock_hass_config_yaml")
@pytest.mark.usefixtures("mock_is_file", "mock_hass_config_yaml")
def test_bad_core_config() -> None:
"""Test a bad core config setup."""
res = check_config.check(get_test_config_dir())
@@ -65,7 +65,7 @@ def test_bad_core_config() -> None:
@pytest.mark.parametrize("hass_config_yaml", [BASE_CONFIG + "light:\n platform: demo"])
@pytest.mark.usefixtures("mock_is_file", "event_loop", "mock_hass_config_yaml")
@pytest.mark.usefixtures("mock_is_file", "mock_hass_config_yaml")
def test_config_platform_valid() -> None:
"""Test a valid platform setup."""
res = check_config.check(get_test_config_dir())
@@ -96,7 +96,7 @@ def test_config_platform_valid() -> None:
),
],
)
@pytest.mark.usefixtures("mock_is_file", "event_loop", "mock_hass_config_yaml")
@pytest.mark.usefixtures("mock_is_file", "mock_hass_config_yaml")
def test_component_platform_not_found(platforms: set[str], error: str) -> None:
"""Test errors if component or platform not found."""
# Make sure they don't exist
@@ -121,7 +121,7 @@ def test_component_platform_not_found(platforms: set[str], error: str) -> None:
}
],
)
@pytest.mark.usefixtures("mock_is_file", "event_loop", "mock_hass_config_yaml")
@pytest.mark.usefixtures("mock_is_file", "mock_hass_config_yaml")
def test_secrets() -> None:
"""Test secrets config checking method."""
res = check_config.check(get_test_config_dir(), True)
@@ -151,7 +151,7 @@ def test_secrets() -> None:
@pytest.mark.parametrize(
"hass_config_yaml", [BASE_CONFIG + ' packages:\n p1:\n group: ["a"]']
)
@pytest.mark.usefixtures("mock_is_file", "event_loop", "mock_hass_config_yaml")
@pytest.mark.usefixtures("mock_is_file", "mock_hass_config_yaml")
def test_package_invalid() -> None:
"""Test an invalid package."""
res = check_config.check(get_test_config_dir())
@@ -168,7 +168,7 @@ def test_package_invalid() -> None:
@pytest.mark.parametrize(
"hass_config_yaml", [BASE_CONFIG + "automation: !include no.yaml"]
)
@pytest.mark.usefixtures("event_loop", "mock_hass_config_yaml")
@pytest.mark.usefixtures("mock_hass_config_yaml")
def test_bootstrap_error() -> None:
"""Test a valid platform setup."""
res = check_config.check(get_test_config_dir(YAML_CONFIG_FILE))