Don't try and store exceptions when the key is missing (#41803)

This commit is contained in:
Tom Parker-Shemilt 2020-10-16 09:01:58 +01:00 committed by GitHub
parent 8bc47c0cd1
commit 2b151209b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -109,7 +109,18 @@ def hass(loop, hass_storage, request):
def exc_handle(loop, context):
"""Handle exceptions by rethrowing them, which will fail the test."""
exceptions.append(context["exception"])
# Most of these contexts will contain an exception, but not all.
# The docs note the key as "optional"
# See https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.call_exception_handler
if "exception" in context:
exceptions.append(context["exception"])
else:
exceptions.append(
Exception(
"Received exception handler without exception, but with message: %s"
% context["message"]
)
)
orig_exception_handler(loop, context)
exceptions = []

View File

@ -16,4 +16,6 @@ IGNORE_UNCAUGHT_EXCEPTIONS = [
"tests.components.unifi.test_controller",
"test_wireless_client_event_calls_update_wireless_devices",
),
("tests.components.iaqualink.test_config_flow", "test_with_invalid_credentials"),
("tests.components.iaqualink.test_config_flow", "test_with_existing_config"),
]