-
Notifications
You must be signed in to change notification settings - Fork 50
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
Print version on debug verbosity level #765
Print version on debug verbosity level #765
Conversation
caplog.set_level(logging.DEBUG) | ||
with pytest.raises(SystemExit): | ||
orion.core.cli.main([""]) | ||
assert "Orion version : " not in caplog.text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good idea to test that the log was effective at the DEBUG level only. Instead of testing with INFO and then with DEBUG you could use record_tuples
to verify the level at which the message was logged:
You can also resort to record_tuples if all you want to do is to ensure, that certain messages have been logged under a given logger name with a given severity and message:
def test_foo(caplog): logging.getLogger().info("boo %s", "arg") assert caplog.record_tuples == [("root", logging.INFO, "boo arg")]
https://docs.pytest.org/en/6.2.x/logging.html#caplog-fixture
src/orion/core/cli/base.py
Outdated
@@ -71,6 +74,7 @@ def parse(self, argv): | |||
format="%(asctime)-15s::%(levelname)s::%(name)s::%(message)s", | |||
level=levels.get(verbose, logging.DEBUG), | |||
) | |||
logger.debug("Orion version : " + orion.core.__version__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have an error here: https://github.com/Epistimio/orion/runs/4939592554?check_suite_focus=true#step:5:15
This is because pylint prefers a format with strings using '%s' instead of concatenating them. So it should rather be
logger.debug("Orion version : %s", orion.core.__version__)
Sorry I didn't catch this in the first place. 😅
PR #771 is merged. I relaunched the tests. |
Description
Prints Orion version if verbose level is debug.
Implements changes requested in issue #735.
Changes
Quite straitforward.
Checklist
Tests
Documentation
Quality
$ tox -e lint
)Further comments
n/a