From 1259979204437235359c0b7cee6dbd7e1ef2f41f Mon Sep 17 00:00:00 2001 From: Ziv <16467659+ziv1234@users.noreply.github.com> Date: Fri, 17 Apr 2020 14:10:48 +0300 Subject: [PATCH] Fix uncaught exception in local_file (#34312) * remove ignore from localfile * added mock_registry * since there are no more exceptions, infra to ignore them is redundant --- tests/components/local_file/test_camera.py | 2 ++ tests/conftest.py | 17 ----------------- tests/ignore_uncaught_exceptions.py | 6 ------ 3 files changed, 2 insertions(+), 23 deletions(-) delete mode 100644 tests/ignore_uncaught_exceptions.py diff --git a/tests/components/local_file/test_camera.py b/tests/components/local_file/test_camera.py index 92650715e5d..ea2b3c3252e 100644 --- a/tests/components/local_file/test_camera.py +++ b/tests/components/local_file/test_camera.py @@ -41,6 +41,8 @@ async def test_loading_file(hass, hass_client): async def test_file_not_readable(hass, caplog): """Test a warning is shown setup when file is not readable.""" + mock_registry(hass) + with mock.patch("os.path.isfile", mock.Mock(return_value=True)), mock.patch( "os.access", mock.Mock(return_value=False) ): diff --git a/tests/conftest.py b/tests/conftest.py index 89a3065bcec..700240bf627 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -19,11 +19,6 @@ from homeassistant.exceptions import ServiceNotFound from homeassistant.setup import async_setup_component from homeassistant.util import location -from tests.ignore_uncaught_exceptions import ( - IGNORE_UNCAUGHT_EXCEPTIONS, - IGNORE_UNCAUGHT_JSON_EXCEPTIONS, -) - pytest.register_assert_rewrite("tests.common") from tests.common import ( # noqa: E402, isort:skip @@ -100,20 +95,8 @@ def hass(loop, hass_storage, request): 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 diff --git a/tests/ignore_uncaught_exceptions.py b/tests/ignore_uncaught_exceptions.py deleted file mode 100644 index d8734ab7316..00000000000 --- a/tests/ignore_uncaught_exceptions.py +++ /dev/null @@ -1,6 +0,0 @@ -"""List of modules that have uncaught exceptions today. Will be shrunk over time.""" -IGNORE_UNCAUGHT_EXCEPTIONS = [ - ("tests.components.local_file.test_camera", "test_file_not_readable"), -] - -IGNORE_UNCAUGHT_JSON_EXCEPTIONS = []