diff --git a/tests/test_config.py b/tests/test_config.py index 67126f087..ae8e987e5 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -65,12 +65,27 @@ def test_proxy_headers(): assert isinstance(config.loaded_app, ProxyHeadersMiddleware) -def test_app_unimportable(): +def test_app_unimportable_module(): config = Config(app="no.such:app") with pytest.raises(ImportError): config.load() +def test_app_unimportable_other(caplog): + config = Config(app="tests.test_config:app") + with pytest.raises(SystemExit): + config.load() + error_messages = [ + record.message + for record in caplog.records + if record.name == "uvicorn.error" and record.levelname == "ERROR" + ] + assert ( + 'Error loading ASGI app. Attribute "app" not found in module "tests.test_config".' # noqa: E501 + == error_messages.pop(0) + ) + + def test_app_factory(): def create_app(): return asgi_app