diff --git a/.travis.yml b/.travis.yml index 8aa781bee..3f07cc511 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,8 +38,8 @@ before_script: script: # Keep the legacy setup.py test approach of checking coverage for python2 - if [[ "$F2B_PY_2" ]]; then coverage run setup.py test; fi - # Coverage doesn't pick up setup.py test with python3, so run it directly - - if [[ "$F2B_PY_3" ]]; then coverage run bin/fail2ban-testcases; fi + # Coverage doesn't pick up setup.py test with python3, so run it directly (with same verbosity as from setup) + - if [[ "$F2B_PY_3" ]]; then coverage run bin/fail2ban-testcases --verbosity=2; fi # Use $VENV_BIN (not python) or else sudo will always run the system's python (2.7) - sudo $VENV_BIN/pip install . # Doc files should get installed on Travis under Linux diff --git a/bin/fail2ban-testcases b/bin/fail2ban-testcases index 4a93ac955..cfd95055d 100755 --- a/bin/fail2ban-testcases +++ b/bin/fail2ban-testcases @@ -61,6 +61,10 @@ def get_opt_parser(): choices=('heavydebug', 'debug', 'info', 'notice', 'warning', 'error', 'critical'), default=None, help="Log level for the logger to use during running tests"), + Option('-v', "--verbosity", action="store", + dest="verbosity", type=int, + default=None, + help="Set numerical level of verbosity (0..4)"), Option("--log-direct", action="store_false", dest="log_lazy", default=True, diff --git a/fail2ban/tests/utils.py b/fail2ban/tests/utils.py index 232da780b..764536bf6 100644 --- a/fail2ban/tests/utils.py +++ b/fail2ban/tests/utils.py @@ -64,7 +64,7 @@ os.putenv('PYTHONPATH', os.path.dirname(os.path.dirname(os.path.dirname( class DefaultTestOptions(optparse.Values): def __init__(self): self.__dict__ = { - 'log_level': None, 'log_lazy': True, + 'log_level': None, 'verbosity': None, 'log_lazy': True, 'log_traceback': None, 'full_traceback': None, 'fast': False, 'memory_db': False, 'no_gamin': False, 'no_network': False, 'negate_re': False @@ -78,15 +78,17 @@ def initProcess(opts): logSys = getLogger("fail2ban") # Numerical level of verbosity corresponding to a log "level" - verbosity = {'heavydebug': 4, - 'debug': 3, - 'info': 2, - 'notice': 2, - 'warning': 1, - 'error': 1, - 'critical': 0, - None: 1}[opts.log_level] - opts.verbosity = verbosity + verbosity = opts.verbosity + if verbosity is None: + verbosity = {'heavydebug': 4, + 'debug': 3, + 'info': 2, + 'notice': 2, + 'warning': 1, + 'error': 1, + 'critical': 0, + None: 1}[opts.log_level] + opts.verbosity = verbosity if opts.log_level is not None: # pragma: no cover # so we had explicit settings