Skip to content

Commit

Permalink
coverage: add access log config coverage (#987)
Browse files Browse the repository at this point in the history
* tests: add access log config coverage

* apply comments
  • Loading branch information
Kludex authored Mar 14, 2021
1 parent ab2d090 commit 862e774
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,18 @@ def test_log_config_file(mocked_logging_config_module):
mocked_logging_config_module.fileConfig.assert_called_once_with(
"log_config", disable_existing_loggers=False
)


@pytest.mark.parametrize(
"access_log, handlers",
[
pytest.param(True, 1, id="access log enabled should have single handler"),
pytest.param(False, 0, id="access log disabled shouldn't have handlers"),
],
)
def test_config_access_log(access_log: bool, handlers: int):
config = Config(app=asgi_app, access_log=access_log)
config.load()

assert len(logging.getLogger("uvicorn.access").handlers) == handlers
assert config.access_log == access_log

0 comments on commit 862e774

Please sign in to comment.