| 225 | |
| 226 | |
| 227 | def test_app_factory(caplog: pytest.LogCaptureFixture) -> None: |
| 228 | def create_app() -> ASGIApplication: |
| 229 | return asgi_app |
| 230 | |
| 231 | config = Config(app=create_app, factory=True, proxy_headers=False) |
| 232 | config.load() |
| 233 | assert config.loaded_app is asgi_app |
| 234 | |
| 235 | class="cm"># Flag not passed. In this case, successfully load the app, but issue a warning |
| 236 | class="cm"># to indicate that an explicit flag is preferred. |
| 237 | caplog.clear() |
| 238 | config = Config(app=create_app, proxy_headers=False) |
| 239 | with caplog.at_level(logging.WARNING): |
| 240 | config.load() |
| 241 | assert config.loaded_app is asgi_app |
| 242 | assert len(caplog.records) == 1 |
| 243 | assert class="st">"--factory" in caplog.records[0].message |
| 244 | |
| 245 | class="cm"># App not a no-arguments callable. |
| 246 | config = Config(app=asgi_app, factory=True) |
| 247 | with pytest.raises(SystemExit): |
| 248 | config.load() |
| 249 | |
| 250 | |
| 251 | def test_concrete_http_class() -> None: |