From 2a7e78a80fedfb74c7e1b7b9aedb8d9729a50011 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 12 Jun 2024 12:21:41 +0200 Subject: [PATCH] Ignore broad-exception-raised pylint warnings in tests (#119468) --- tests/components/bluetooth/test_passive_update_processor.py | 2 ++ tests/components/notify/test_legacy.py | 2 +- tests/components/profiler/test_init.py | 2 +- tests/components/roon/test_config_flow.py | 2 +- tests/components/system_health/test_init.py | 2 +- tests/components/system_log/test_init.py | 2 +- tests/helpers/test_dispatcher.py | 2 ++ tests/test_config_entries.py | 2 +- tests/test_core.py | 4 ++-- tests/test_runner.py | 3 ++- tests/test_setup.py | 5 +++-- tests/util/test_logging.py | 1 + 12 files changed, 18 insertions(+), 11 deletions(-) diff --git a/tests/components/bluetooth/test_passive_update_processor.py b/tests/components/bluetooth/test_passive_update_processor.py index 24cf344a31c..8e1163c0bdb 100644 --- a/tests/components/bluetooth/test_passive_update_processor.py +++ b/tests/components/bluetooth/test_passive_update_processor.py @@ -583,6 +583,7 @@ async def test_exception_from_update_method( nonlocal run_count run_count += 1 if run_count == 2: + # pylint: disable-next=broad-exception-raised raise Exception("Test exception") return GENERIC_PASSIVE_BLUETOOTH_DATA_UPDATE @@ -1417,6 +1418,7 @@ async def test_exception_from_coordinator_update_method( nonlocal run_count run_count += 1 if run_count == 2: + # pylint: disable-next=broad-exception-raised raise Exception("Test exception") return {"test": "data"} diff --git a/tests/components/notify/test_legacy.py b/tests/components/notify/test_legacy.py index cc2192461ae..d6478c358bf 100644 --- a/tests/components/notify/test_legacy.py +++ b/tests/components/notify/test_legacy.py @@ -261,7 +261,7 @@ async def test_platform_setup_with_error( async def async_get_service(hass, config, discovery_info=None): """Return None for an invalid notify service.""" - raise Exception("Setup error") + raise Exception("Setup error") # pylint: disable=broad-exception-raised mock_notify_platform( hass, tmp_path, "testnotify", async_get_service=async_get_service diff --git a/tests/components/profiler/test_init.py b/tests/components/profiler/test_init.py index ba605049e72..2eca84b43fe 100644 --- a/tests/components/profiler/test_init.py +++ b/tests/components/profiler/test_init.py @@ -181,7 +181,7 @@ async def test_dump_log_object( def __repr__(self): if self.fail: - raise Exception("failed") + raise Exception("failed") # pylint: disable=broad-exception-raised return "" obj1 = DumpLogDummy(False) diff --git a/tests/components/roon/test_config_flow.py b/tests/components/roon/test_config_flow.py index 6f83331d1c7..9822c88fa48 100644 --- a/tests/components/roon/test_config_flow.py +++ b/tests/components/roon/test_config_flow.py @@ -48,7 +48,7 @@ class RoonApiMockException(RoonApiMock): @property def token(self): """Throw exception.""" - raise Exception + raise Exception # pylint: disable=broad-exception-raised class RoonDiscoveryMock: diff --git a/tests/components/system_health/test_init.py b/tests/components/system_health/test_init.py index e677b7d1d34..e51ab8fab99 100644 --- a/tests/components/system_health/test_init.py +++ b/tests/components/system_health/test_init.py @@ -110,7 +110,7 @@ async def test_info_endpoint_register_callback_exc( """Test that the info endpoint requires auth.""" async def mock_info(hass): - raise Exception("TEST ERROR") + raise Exception("TEST ERROR") # pylint: disable=broad-exception-raised async_register_info(hass, "lovelace", mock_info) assert await async_setup_component(hass, "system_health", {}) diff --git a/tests/components/system_log/test_init.py b/tests/components/system_log/test_init.py index e9a50f62cee..0e301720aeb 100644 --- a/tests/components/system_log/test_init.py +++ b/tests/components/system_log/test_init.py @@ -35,7 +35,7 @@ async def get_error_log(hass_ws_client): def _generate_and_log_exception(exception, log): try: - raise Exception(exception) + raise Exception(exception) # pylint: disable=broad-exception-raised except Exception: _LOGGER.exception(log) diff --git a/tests/helpers/test_dispatcher.py b/tests/helpers/test_dispatcher.py index 89d05407fbd..c2c8663f47c 100644 --- a/tests/helpers/test_dispatcher.py +++ b/tests/helpers/test_dispatcher.py @@ -188,6 +188,7 @@ async def test_callback_exception_gets_logged( @callback def bad_handler(*args): """Record calls.""" + # pylint: disable-next=broad-exception-raised raise Exception("This is a bad message callback") # wrap in partial to test message logging. @@ -208,6 +209,7 @@ async def test_coro_exception_gets_logged( async def bad_async_handler(*args): """Record calls.""" + # pylint: disable-next=broad-exception-raised raise Exception("This is a bad message in a coro") # wrap in partial to test message logging. diff --git a/tests/test_config_entries.py b/tests/test_config_entries.py index 0208b33169c..2d946dd1fce 100644 --- a/tests/test_config_entries.py +++ b/tests/test_config_entries.py @@ -576,7 +576,7 @@ async def test_remove_entry_raises( async def mock_unload_entry(hass, entry): """Mock unload entry function.""" - raise Exception("BROKEN") + raise Exception("BROKEN") # pylint: disable=broad-exception-raised mock_integration(hass, MockModule("comp", async_unload_entry=mock_unload_entry)) diff --git a/tests/test_core.py b/tests/test_core.py index 71e6cb3f3b6..7787a9a3769 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -423,11 +423,11 @@ async def test_async_get_hass_can_be_called(hass: HomeAssistant) -> None: try: if ha.async_get_hass() is hass: return True - raise Exception + raise Exception # pylint: disable=broad-exception-raised except HomeAssistantError: return False - raise Exception + raise Exception # pylint: disable=broad-exception-raised # Test scheduling a coroutine which calls async_get_hass via hass.async_create_task async def _async_create_task() -> None: diff --git a/tests/test_runner.py b/tests/test_runner.py index a4bec12bc0d..90678454adf 100644 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -104,7 +104,7 @@ def test_run_does_not_block_forever_with_shielded_task( try: await asyncio.sleep(2) except asyncio.CancelledError: - raise Exception + raise Exception # pylint: disable=broad-exception-raised async def async_shielded(*_): try: @@ -141,6 +141,7 @@ async def test_unhandled_exception_traceback( async def _unhandled_exception(): raised.set() + # pylint: disable-next=broad-exception-raised raise Exception("This is unhandled") try: diff --git a/tests/test_setup.py b/tests/test_setup.py index 27d4b32d32f..f15fe72603e 100644 --- a/tests/test_setup.py +++ b/tests/test_setup.py @@ -328,7 +328,7 @@ async def test_component_exception_setup(hass: HomeAssistant) -> None: def exception_setup(hass, config): """Raise exception.""" - raise Exception("fail!") + raise Exception("fail!") # pylint: disable=broad-exception-raised mock_integration(hass, MockModule("comp", setup=exception_setup)) @@ -342,7 +342,7 @@ async def test_component_base_exception_setup(hass: HomeAssistant) -> None: def exception_setup(hass, config): """Raise exception.""" - raise BaseException("fail!") + raise BaseException("fail!") # pylint: disable=broad-exception-raised mock_integration(hass, MockModule("comp", setup=exception_setup)) @@ -362,6 +362,7 @@ async def test_component_setup_with_validation_and_dependency( """Test that config is passed in.""" if config.get("comp_a", {}).get("valid", False): return True + # pylint: disable-next=broad-exception-raised raise Exception(f"Config not passed in: {config}") platform = MockPlatform() diff --git a/tests/util/test_logging.py b/tests/util/test_logging.py index 8e7106475a2..4667dbcbec8 100644 --- a/tests/util/test_logging.py +++ b/tests/util/test_logging.py @@ -80,6 +80,7 @@ async def test_async_create_catching_coro( """Test exception logging of wrapped coroutine.""" async def job(): + # pylint: disable-next=broad-exception-raised raise Exception("This is a bad coroutine") hass.async_create_task(logging_util.async_create_catching_coro(job()))