From 2b151209b2edb2771dc81ca101598811248d3ea6 Mon Sep 17 00:00:00 2001 From: Tom Parker-Shemilt Date: Fri, 16 Oct 2020 09:01:58 +0100 Subject: [PATCH] Don't try and store exceptions when the key is missing (#41803) --- tests/conftest.py | 13 ++++++++++++- tests/ignore_uncaught_exceptions.py | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 1b4d54a6fdb..285179e3a9b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 = [] diff --git a/tests/ignore_uncaught_exceptions.py b/tests/ignore_uncaught_exceptions.py index e68131d689b..5f991d15bbf 100644 --- a/tests/ignore_uncaught_exceptions.py +++ b/tests/ignore_uncaught_exceptions.py @@ -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"), ]