Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coverage: add log level config coverage #986

Merged
merged 3 commits into from
Mar 14, 2021
Merged

coverage: add log level config coverage #986

merged 3 commits into from
Mar 14, 2021

Conversation

Kludex
Copy link
Member

@Kludex Kludex commented Mar 8, 2021

Covering:

        if self.log_level is not None:
            if isinstance(self.log_level, str):
                log_level = LOG_LEVELS[self.log_level]
            else:
                log_level = self.log_level  # THIS

File: config.py

@@ -247,3 +247,11 @@ 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("log_level", [5, 10, 20, 30, 40, 50])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we pass an int ? I have to say I always used this with a string level

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, there's a cast in place... In case is different than str and int, you'll have a KeyError tho.


@pytest.mark.parametrize("log_level", [5, 10, 20, 30, 40, 50])
def test_config_log_level(log_level):
Config(app=asgi_app, log_level=log_level)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why config is not loaded ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied.

tests/test_config.py Show resolved Hide resolved
@Kludex
Copy link
Member Author

Kludex commented Mar 9, 2021

@euri10 Comments applied. Thank you. :)

Copy link
Member

@euri10 euri10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a rebase later and we gtg @Kludex , thanks !

@euri10 euri10 changed the title tests: add log level config coverage coverage: add log level config coverage Mar 14, 2021
@Kludex
Copy link
Member Author

Kludex commented Mar 14, 2021

@euri10 done. Thank you :)

@euri10 euri10 merged commit bf1c64e into encode:master Mar 14, 2021
Kludex added a commit to sephioh/uvicorn that referenced this pull request Oct 29, 2022
* tests: add log level config coverage

* apply comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants