From 689421eddf72f56302b348c89c6f66c2fc938f06 Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Wed, 19 Feb 2025 06:14:07 +0100 Subject: [PATCH] Move blocking code to executor job in MQTT CI test helper (#138815) --- tests/components/mqtt/test_common.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/components/mqtt/test_common.py b/tests/components/mqtt/test_common.py index a34907adbaf..3bb8657e2f2 100644 --- a/tests/components/mqtt/test_common.py +++ b/tests/components/mqtt/test_common.py @@ -1854,9 +1854,14 @@ async def help_test_reload_with_config( ) -> None: """Test reloading with supplied config.""" new_yaml_config_file = tmp_path / "configuration.yaml" - new_yaml_config = yaml.dump(config) - new_yaml_config_file.write_text(new_yaml_config) - assert new_yaml_config_file.read_text() == new_yaml_config + + def _write_yaml_config() -> None: + new_yaml_config = yaml.dump(config) + new_yaml_config_file.write_text(new_yaml_config) + assert new_yaml_config_file.read_text() == new_yaml_config + return new_yaml_config + + await hass.async_add_executor_job(_write_yaml_config) with patch.object(module_hass_config, "YAML_CONFIG_FILE", new_yaml_config_file): await hass.services.async_call(