Fix handling of empty google_calendars.yaml file (#84909)

fixes undefined
This commit is contained in:
Allen Porter 2022-12-31 02:50:56 -08:00 committed by GitHub
parent fbb406842e
commit 6b6f115d7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 2 deletions

View file

@ -121,7 +121,9 @@ def mock_calendars_yaml(
calendars_config: list[dict[str, Any]],
) -> Generator[Mock, None, None]:
"""Fixture that prepares the google_calendars.yaml mocks."""
mocked_open_function = mock_open(read_data=yaml.dump(calendars_config))
mocked_open_function = mock_open(
read_data=yaml.dump(calendars_config) if calendars_config else None
)
with patch("homeassistant.components.google.open", mocked_open_function):
yield mocked_open_function