def hass(loop, hass_storage, request): """Fixture to provide a test instance of Home Assistant.""" def exc_handle(loop, context): """Handle exceptions by rethrowing them, which will fail the test.""" exceptions.append(context["exception"]) orig_exception_handler(loop, context) exceptions = [] hass = loop.run_until_complete(async_test_home_assistant(loop)) orig_exception_handler = loop.get_exception_handler() loop.set_exception_handler(exc_handle) yield hass loop.run_until_complete(hass.async_stop(force=True)) for ex in exceptions: if ( request.module.__name__, request.function.__name__, ) in IGNORE_UNCAUGHT_EXCEPTIONS: continue if isinstance(ex, ServiceNotFound): continue if ( isinstance(ex, TypeError) and "is not JSON serializable" in str(ex) and (request.module.__name__, request.function.__name__) in IGNORE_UNCAUGHT_JSON_EXCEPTIONS ): continue raise ex
def hass(loop, load_registries, hass_storage, request): """Fixture to provide a test instance of Home Assistant.""" def exc_handle(loop, context): """Handle exceptions by rethrowing them, which will fail the test.""" # 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 = [] hass = loop.run_until_complete( async_test_home_assistant(loop, load_registries)) orig_exception_handler = loop.get_exception_handler() loop.set_exception_handler(exc_handle) yield hass loop.run_until_complete(hass.async_stop(force=True)) for ex in exceptions: if ( request.module.__name__, request.function.__name__, ) in IGNORE_UNCAUGHT_EXCEPTIONS: continue raise ex
def hass(loop): """Fixture to provide a test instance of HASS.""" hass = loop.run_until_complete(async_test_home_assistant(loop)) yield hass loop.run_until_complete(hass.async_stop())
def hass(loop, hass_storage): """Fixture to provide a test instance of HASS.""" hass = loop.run_until_complete(async_test_home_assistant(loop)) yield hass loop.run_until_complete(hass.async_stop(force=True))
def hass(loop): """Home Assistant fixture with device mapping registry.""" hass = loop.run_until_complete(async_test_home_assistant(loop)) hass.data[spc.DATA_REGISTRY] = spc.SpcRegistry() hass.data[spc.DATA_API] = None yield hass loop.run_until_complete(hass.async_stop())
def hass(loop): """Home Assistant fixture with device mapping registry.""" hass = loop.run_until_complete(async_test_home_assistant(loop)) hass.data['spc_registry'] = SpcRegistry() hass.data['spc_api'] = None yield hass loop.run_until_complete(hass.async_stop())
def hass(event_loop, tmpdir): """Fixture to provide a test instance of Home Assistant.""" def exc_handle(event_loop, context): """Handle exceptions by rethrowing them, which will fail the test.""" # 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(event_loop, context) exceptions = [] hass = event_loop.run_until_complete( async_test_home_assistant(event_loop, tmpdir)) orig_exception_handler = event_loop.get_exception_handler() event_loop.set_exception_handler(exc_handle) yield hass event_loop.run_until_complete(hass.async_stop(force=True)) for ex in exceptions: if isinstance(ex, (ServiceNotFound, FileExistsError)): continue raise ex
def hass(loop, hass_storage, request): """Fixture to provide a test instance of Home Assistant.""" def exc_handle(loop, context): """Handle exceptions by rethrowing them, which will fail the test.""" exceptions.append(context["exception"]) orig_exception_handler(loop, context) exceptions = [] hass = loop.run_until_complete(async_test_home_assistant(loop)) orig_exception_handler = loop.get_exception_handler() loop.set_exception_handler(exc_handle) yield hass loop.run_until_complete(hass.async_stop(force=True)) for ex in exceptions: if isinstance(ex, ServiceNotFound): continue raise ex