Add type hints for pytest.LogCaptureFixture in test fixtures (#118687)

This commit is contained in:
epenet 2024-06-03 09:28:54 +02:00 committed by GitHub
parent bb259b607f
commit 9a5706fa30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 6 deletions

View File

@ -21,7 +21,7 @@ query_icon_matching = [
@pytest.fixture(name="tvliftbox")
def tv_lift_box_fixture(caplog):
def tv_lift_box_fixture(caplog: pytest.LogCaptureFixture):
"""Return simple button entity mock."""
caplog.set_level(logging.ERROR)

View File

@ -117,7 +117,12 @@ def mock_pymodbus_fixture(do_exception, register_words):
@pytest.fixture(name="mock_modbus")
async def mock_modbus_fixture(
hass, caplog, check_config_loaded, config_addon, do_config, mock_pymodbus
hass: HomeAssistant,
caplog: pytest.LogCaptureFixture,
check_config_loaded,
config_addon,
do_config,
mock_pymodbus,
):
"""Load integration modbus using mocked pymodbus."""
conf = copy.deepcopy(do_config)
@ -192,6 +197,6 @@ async def mock_modbus_ha_fixture(hass, mock_modbus):
@pytest.fixture(name="caplog_setup_text")
async def caplog_setup_text_fixture(caplog):
async def caplog_setup_text_fixture(caplog: pytest.LogCaptureFixture) -> str:
"""Return setup log of integration."""
return caplog.text

View File

@ -136,7 +136,9 @@ from tests.common import async_fire_time_changed, get_fixture_path
@pytest.fixture(name="mock_modbus_with_pymodbus")
async def mock_modbus_with_pymodbus_fixture(hass, caplog, do_config, mock_pymodbus):
async def mock_modbus_with_pymodbus_fixture(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, do_config, mock_pymodbus
):
"""Load integration modbus using mocked pymodbus."""
caplog.clear()
caplog.set_level(logging.ERROR)
@ -1361,12 +1363,12 @@ async def test_pb_service_write(
@pytest.fixture(name="mock_modbus_read_pymodbus")
async def mock_modbus_read_pymodbus_fixture(
hass,
hass: HomeAssistant,
do_group,
do_type,
do_scan_interval,
do_return,
caplog,
caplog: pytest.LogCaptureFixture,
mock_pymodbus,
freezer: FrozenDateTimeFactory,
):