Ignore broad-exception-raised pylint warnings in tests (#119468)
This commit is contained in:
parent
0c79eeabdf
commit
2a7e78a80f
12 changed files with 18 additions and 11 deletions
|
@ -583,6 +583,7 @@ async def test_exception_from_update_method(
|
||||||
nonlocal run_count
|
nonlocal run_count
|
||||||
run_count += 1
|
run_count += 1
|
||||||
if run_count == 2:
|
if run_count == 2:
|
||||||
|
# pylint: disable-next=broad-exception-raised
|
||||||
raise Exception("Test exception")
|
raise Exception("Test exception")
|
||||||
return GENERIC_PASSIVE_BLUETOOTH_DATA_UPDATE
|
return GENERIC_PASSIVE_BLUETOOTH_DATA_UPDATE
|
||||||
|
|
||||||
|
@ -1417,6 +1418,7 @@ async def test_exception_from_coordinator_update_method(
|
||||||
nonlocal run_count
|
nonlocal run_count
|
||||||
run_count += 1
|
run_count += 1
|
||||||
if run_count == 2:
|
if run_count == 2:
|
||||||
|
# pylint: disable-next=broad-exception-raised
|
||||||
raise Exception("Test exception")
|
raise Exception("Test exception")
|
||||||
return {"test": "data"}
|
return {"test": "data"}
|
||||||
|
|
||||||
|
|
|
@ -261,7 +261,7 @@ async def test_platform_setup_with_error(
|
||||||
|
|
||||||
async def async_get_service(hass, config, discovery_info=None):
|
async def async_get_service(hass, config, discovery_info=None):
|
||||||
"""Return None for an invalid notify service."""
|
"""Return None for an invalid notify service."""
|
||||||
raise Exception("Setup error")
|
raise Exception("Setup error") # pylint: disable=broad-exception-raised
|
||||||
|
|
||||||
mock_notify_platform(
|
mock_notify_platform(
|
||||||
hass, tmp_path, "testnotify", async_get_service=async_get_service
|
hass, tmp_path, "testnotify", async_get_service=async_get_service
|
||||||
|
|
|
@ -181,7 +181,7 @@ async def test_dump_log_object(
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
if self.fail:
|
if self.fail:
|
||||||
raise Exception("failed")
|
raise Exception("failed") # pylint: disable=broad-exception-raised
|
||||||
return "<DumpLogDummy success>"
|
return "<DumpLogDummy success>"
|
||||||
|
|
||||||
obj1 = DumpLogDummy(False)
|
obj1 = DumpLogDummy(False)
|
||||||
|
|
|
@ -48,7 +48,7 @@ class RoonApiMockException(RoonApiMock):
|
||||||
@property
|
@property
|
||||||
def token(self):
|
def token(self):
|
||||||
"""Throw exception."""
|
"""Throw exception."""
|
||||||
raise Exception
|
raise Exception # pylint: disable=broad-exception-raised
|
||||||
|
|
||||||
|
|
||||||
class RoonDiscoveryMock:
|
class RoonDiscoveryMock:
|
||||||
|
|
|
@ -110,7 +110,7 @@ async def test_info_endpoint_register_callback_exc(
|
||||||
"""Test that the info endpoint requires auth."""
|
"""Test that the info endpoint requires auth."""
|
||||||
|
|
||||||
async def mock_info(hass):
|
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)
|
async_register_info(hass, "lovelace", mock_info)
|
||||||
assert await async_setup_component(hass, "system_health", {})
|
assert await async_setup_component(hass, "system_health", {})
|
||||||
|
|
|
@ -35,7 +35,7 @@ async def get_error_log(hass_ws_client):
|
||||||
|
|
||||||
def _generate_and_log_exception(exception, log):
|
def _generate_and_log_exception(exception, log):
|
||||||
try:
|
try:
|
||||||
raise Exception(exception)
|
raise Exception(exception) # pylint: disable=broad-exception-raised
|
||||||
except Exception:
|
except Exception:
|
||||||
_LOGGER.exception(log)
|
_LOGGER.exception(log)
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,7 @@ async def test_callback_exception_gets_logged(
|
||||||
@callback
|
@callback
|
||||||
def bad_handler(*args):
|
def bad_handler(*args):
|
||||||
"""Record calls."""
|
"""Record calls."""
|
||||||
|
# pylint: disable-next=broad-exception-raised
|
||||||
raise Exception("This is a bad message callback")
|
raise Exception("This is a bad message callback")
|
||||||
|
|
||||||
# wrap in partial to test message logging.
|
# wrap in partial to test message logging.
|
||||||
|
@ -208,6 +209,7 @@ async def test_coro_exception_gets_logged(
|
||||||
|
|
||||||
async def bad_async_handler(*args):
|
async def bad_async_handler(*args):
|
||||||
"""Record calls."""
|
"""Record calls."""
|
||||||
|
# pylint: disable-next=broad-exception-raised
|
||||||
raise Exception("This is a bad message in a coro")
|
raise Exception("This is a bad message in a coro")
|
||||||
|
|
||||||
# wrap in partial to test message logging.
|
# wrap in partial to test message logging.
|
||||||
|
|
|
@ -576,7 +576,7 @@ async def test_remove_entry_raises(
|
||||||
|
|
||||||
async def mock_unload_entry(hass, entry):
|
async def mock_unload_entry(hass, entry):
|
||||||
"""Mock unload entry function."""
|
"""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))
|
mock_integration(hass, MockModule("comp", async_unload_entry=mock_unload_entry))
|
||||||
|
|
||||||
|
|
|
@ -423,11 +423,11 @@ async def test_async_get_hass_can_be_called(hass: HomeAssistant) -> None:
|
||||||
try:
|
try:
|
||||||
if ha.async_get_hass() is hass:
|
if ha.async_get_hass() is hass:
|
||||||
return True
|
return True
|
||||||
raise Exception
|
raise Exception # pylint: disable=broad-exception-raised
|
||||||
except HomeAssistantError:
|
except HomeAssistantError:
|
||||||
return False
|
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
|
# Test scheduling a coroutine which calls async_get_hass via hass.async_create_task
|
||||||
async def _async_create_task() -> None:
|
async def _async_create_task() -> None:
|
||||||
|
|
|
@ -104,7 +104,7 @@ def test_run_does_not_block_forever_with_shielded_task(
|
||||||
try:
|
try:
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(2)
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
raise Exception
|
raise Exception # pylint: disable=broad-exception-raised
|
||||||
|
|
||||||
async def async_shielded(*_):
|
async def async_shielded(*_):
|
||||||
try:
|
try:
|
||||||
|
@ -141,6 +141,7 @@ async def test_unhandled_exception_traceback(
|
||||||
|
|
||||||
async def _unhandled_exception():
|
async def _unhandled_exception():
|
||||||
raised.set()
|
raised.set()
|
||||||
|
# pylint: disable-next=broad-exception-raised
|
||||||
raise Exception("This is unhandled")
|
raise Exception("This is unhandled")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -328,7 +328,7 @@ async def test_component_exception_setup(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
def exception_setup(hass, config):
|
def exception_setup(hass, config):
|
||||||
"""Raise exception."""
|
"""Raise exception."""
|
||||||
raise Exception("fail!")
|
raise Exception("fail!") # pylint: disable=broad-exception-raised
|
||||||
|
|
||||||
mock_integration(hass, MockModule("comp", setup=exception_setup))
|
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):
|
def exception_setup(hass, config):
|
||||||
"""Raise exception."""
|
"""Raise exception."""
|
||||||
raise BaseException("fail!")
|
raise BaseException("fail!") # pylint: disable=broad-exception-raised
|
||||||
|
|
||||||
mock_integration(hass, MockModule("comp", setup=exception_setup))
|
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."""
|
"""Test that config is passed in."""
|
||||||
if config.get("comp_a", {}).get("valid", False):
|
if config.get("comp_a", {}).get("valid", False):
|
||||||
return True
|
return True
|
||||||
|
# pylint: disable-next=broad-exception-raised
|
||||||
raise Exception(f"Config not passed in: {config}")
|
raise Exception(f"Config not passed in: {config}")
|
||||||
|
|
||||||
platform = MockPlatform()
|
platform = MockPlatform()
|
||||||
|
|
|
@ -80,6 +80,7 @@ async def test_async_create_catching_coro(
|
||||||
"""Test exception logging of wrapped coroutine."""
|
"""Test exception logging of wrapped coroutine."""
|
||||||
|
|
||||||
async def job():
|
async def job():
|
||||||
|
# pylint: disable-next=broad-exception-raised
|
||||||
raise Exception("This is a bad coroutine")
|
raise Exception("This is a bad coroutine")
|
||||||
|
|
||||||
hass.async_create_task(logging_util.async_create_catching_coro(job()))
|
hass.async_create_task(logging_util.async_create_catching_coro(job()))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue