mirror of https://github.com/fail2ban/fail2ban
new test-cases option "--verbosity" to set numeric level of verbosity during test cases;
travis uses same verbosity (2) running in python3 as from setup (python2)pull/1515/head
parent
e3f4ea7284
commit
cd6b528542
|
@ -38,8 +38,8 @@ before_script:
|
||||||
script:
|
script:
|
||||||
# Keep the legacy setup.py test approach of checking coverage for python2
|
# Keep the legacy setup.py test approach of checking coverage for python2
|
||||||
- if [[ "$F2B_PY_2" ]]; then coverage run setup.py test; fi
|
- 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
|
# 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; fi
|
- 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)
|
# Use $VENV_BIN (not python) or else sudo will always run the system's python (2.7)
|
||||||
- sudo $VENV_BIN/pip install .
|
- sudo $VENV_BIN/pip install .
|
||||||
# Doc files should get installed on Travis under Linux
|
# Doc files should get installed on Travis under Linux
|
||||||
|
|
|
@ -61,6 +61,10 @@ def get_opt_parser():
|
||||||
choices=('heavydebug', 'debug', 'info', 'notice', 'warning', 'error', 'critical'),
|
choices=('heavydebug', 'debug', 'info', 'notice', 'warning', 'error', 'critical'),
|
||||||
default=None,
|
default=None,
|
||||||
help="Log level for the logger to use during running tests"),
|
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",
|
Option("--log-direct", action="store_false",
|
||||||
dest="log_lazy",
|
dest="log_lazy",
|
||||||
default=True,
|
default=True,
|
||||||
|
|
|
@ -64,7 +64,7 @@ os.putenv('PYTHONPATH', os.path.dirname(os.path.dirname(os.path.dirname(
|
||||||
class DefaultTestOptions(optparse.Values):
|
class DefaultTestOptions(optparse.Values):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.__dict__ = {
|
self.__dict__ = {
|
||||||
'log_level': None, 'log_lazy': True,
|
'log_level': None, 'verbosity': None, 'log_lazy': True,
|
||||||
'log_traceback': None, 'full_traceback': None,
|
'log_traceback': None, 'full_traceback': None,
|
||||||
'fast': False, 'memory_db': False, 'no_gamin': False,
|
'fast': False, 'memory_db': False, 'no_gamin': False,
|
||||||
'no_network': False, 'negate_re': False
|
'no_network': False, 'negate_re': False
|
||||||
|
@ -78,15 +78,17 @@ def initProcess(opts):
|
||||||
logSys = getLogger("fail2ban")
|
logSys = getLogger("fail2ban")
|
||||||
|
|
||||||
# Numerical level of verbosity corresponding to a log "level"
|
# Numerical level of verbosity corresponding to a log "level"
|
||||||
verbosity = {'heavydebug': 4,
|
verbosity = opts.verbosity
|
||||||
'debug': 3,
|
if verbosity is None:
|
||||||
'info': 2,
|
verbosity = {'heavydebug': 4,
|
||||||
'notice': 2,
|
'debug': 3,
|
||||||
'warning': 1,
|
'info': 2,
|
||||||
'error': 1,
|
'notice': 2,
|
||||||
'critical': 0,
|
'warning': 1,
|
||||||
None: 1}[opts.log_level]
|
'error': 1,
|
||||||
opts.verbosity = verbosity
|
'critical': 0,
|
||||||
|
None: 1}[opts.log_level]
|
||||||
|
opts.verbosity = verbosity
|
||||||
|
|
||||||
if opts.log_level is not None: # pragma: no cover
|
if opts.log_level is not None: # pragma: no cover
|
||||||
# so we had explicit settings
|
# so we had explicit settings
|
||||||
|
|
Loading…
Reference in New Issue