You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pytest adds a new --odoo-log-level option which is forwarded as odoo's log level.
By default it uses the critical log level to display the less logs possible. But you can change it when you need more details for debugging a test.
Odoo has 2 options for configuring log levels:
--log-level: a global single level (critical, error, info, debug, ...)
--log-handler: a refined log level per logger name (':INFO,odoo.http.rpc.request:INFO')
# means critical log-level
pytest -s my_addon/tests
The log levels will be:
:INFO
odoo:CRITICAL
werkzeug:CRITICAL
As the log levels are recursive, all the loggers below odoo (odoo.addons.sale, ...) and werkzeug will be on the critical log-level. But all other loggers, such as those used by libs (Pillow, ...) will have an INFO logger by default.
What we should probably do is set a default --log-handler to :CRITICAL and add an option to modify it the same way it's done for the log level.
As a workaround, you can use a configuration file (
Now, we observed in #15 that even logs in DEBUG of Pillow (and passlib) were shown, and they should have been hidden as the default is INFO.
The reason is that each test is in a context manager (pytest.logging.catching_logs) which, during the duration of the test, sets the root loglevel to zero (0 is below DEBUG, display everything). Predefined children log levels will not be changed, but others will all show debug logs. (introduced at pytest-dev/pytest#3013)
Pytest adds a new
--odoo-log-level
option which is forwarded as odoo's log level.By default it uses the
critical
log level to display the less logs possible. But you can change it when you need more details for debugging a test.Odoo has 2 options for configuring log levels:
--log-level
: a global single level (critical, error, info, debug, ...)--log-handler
: a refined log level per logger name (':INFO,odoo.http.rpc.request:INFO')The first one is based on this config:
And the second one will be applied after the
--log-level
, so it overrides it.The default log handler is
:INFO
.The result is that when you use a command such as (both are the same):
The log levels will be:
As the log levels are recursive, all the loggers below odoo (
odoo.addons.sale
, ...) and werkzeug will be on the critical log-level. But all other loggers, such as those used by libs (Pillow, ...) will have an INFO logger by default.What we should probably do is set a default
--log-handler
to:CRITICAL
and add an option to modify it the same way it's done for the log level.As a workaround, you can use a configuration file (
pytest-odoo/pytest_odoo.py
Line 41 in 33e4e63
Now, we observed in #15 that even logs in DEBUG of Pillow (and passlib) were shown, and they should have been hidden as the default is INFO.
The reason is that each test is in a context manager (pytest.logging.catching_logs) which, during the duration of the test, sets the root loglevel to zero (0 is below DEBUG, display everything). Predefined children log levels will not be changed, but others will all show debug logs. (introduced at pytest-dev/pytest#3013)
The context manager: https://github.com/pytest-dev/pytest/blob/5ad1313b8a18fa3862623d2360cbeb39c202b838/_pytest/logging.py#L84-L106
Hopefully, it has been fixed in pytest 3.4.2 (pytest-dev/pytest@8dcd271)
The text was updated successfully, but these errors were encountered: