Remove fixture

This commit is contained in:
G Johansson
2025-08-16 16:00:04 +00:00
parent 0d4302767b
commit e8d5cb2acb

View File

@@ -3,14 +3,10 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Generator from collections.abc import Generator
from pathlib import Path
import sqlite3
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
import pytest import pytest
from homeassistant.core import HomeAssistant
@pytest.fixture @pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock]: def mock_setup_entry() -> Generator[AsyncMock]:
@@ -19,23 +15,3 @@ def mock_setup_entry() -> Generator[AsyncMock]:
"homeassistant.components.sql.async_setup_entry", return_value=True "homeassistant.components.sql.async_setup_entry", return_value=True
) as mock_setup_entry: ) as mock_setup_entry:
yield mock_setup_entry yield mock_setup_entry
@pytest.fixture
async def create_db(
hass: HomeAssistant,
tmp_path: Path,
) -> str:
"""Test the SQL sensor with a query that returns no value."""
db_path = tmp_path / "test.db"
db_path_str = f"sqlite:///{db_path}"
def make_test_db():
"""Create a test database."""
conn = sqlite3.connect(db_path)
conn.execute("CREATE TABLE users (value INTEGER)")
conn.commit()
conn.close()
await hass.async_add_executor_job(make_test_db)
return db_path_str