From 785790b930ef0d02716294475b789cc9a0e3829e Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 4 May 2017 16:23:35 +0200 Subject: [PATCH] [enh] Add a custom --yunodebug option for pytest (#303) --- src/yunohost/tests/conftest.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/yunohost/tests/conftest.py b/src/yunohost/tests/conftest.py index f979d1b42..946eec23c 100644 --- a/src/yunohost/tests/conftest.py +++ b/src/yunohost/tests/conftest.py @@ -3,6 +3,10 @@ import moulinette sys.path.append("..") + +def pytest_addoption(parser): + parser.addoption("--yunodebug", action="store_true", default=False) + ############################################################################### # Tweak moulinette init to have yunohost namespace # ############################################################################### @@ -39,7 +43,7 @@ moulinette.core.Moulinette18n.n = new_m18nn ############################################################################### -def _init_moulinette(): +def pytest_cmdline_main(config): """Configure logging and initialize the moulinette""" # Define loggers handlers handlers = set(['tty']) @@ -47,7 +51,10 @@ def _init_moulinette(): # Define loggers level level = 'INFO' - tty_level = 'SUCCESS' + if config.option.yunodebug: + tty_level = 'DEBUG' + else: + tty_level = 'SUCCESS' # Custom logging configuration logging = { @@ -99,5 +106,3 @@ def _init_moulinette(): # Initialize moulinette moulinette.init(logging_config=logging, _from_source=False) - -_init_moulinette()