Ignore broad-exception-raised pylint warnings in tests (#119468)

This commit is contained in:
epenet 2024-06-12 12:21:41 +02:00 committed by GitHub
parent 0c79eeabdf
commit 2a7e78a80f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 18 additions and 11 deletions

View file

@ -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"}

View file

@ -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

View file

@ -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 "<DumpLogDummy success>"
obj1 = DumpLogDummy(False)

View file

@ -48,7 +48,7 @@ class RoonApiMockException(RoonApiMock):
@property
def token(self):
"""Throw exception."""
raise Exception
raise Exception # pylint: disable=broad-exception-raised
class RoonDiscoveryMock:

View file

@ -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", {})

View file

@ -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)

View file

@ -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.

View file

@ -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))

View file

@ -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:

View file

@ -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:

View file

@ -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()

View file

@ -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()))