Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
coloredlogs.install()
coloredlogs.set_level(logging.DEBUG)
def test_increase_verbosity(self):
"""Make sure increase_verbosity() respects default and custom levels."""
# Start from a known state.
set_level(logging.INFO)
assert get_level() == logging.INFO
# INFO -> VERBOSE.
increase_verbosity()
assert get_level() == logging.VERBOSE
# VERBOSE -> DEBUG.
increase_verbosity()
assert get_level() == logging.DEBUG
# DEBUG -> SPAM.
increase_verbosity()
assert get_level() == logging.SPAM
# SPAM -> NOTSET.
increase_verbosity()
assert get_level() == logging.NOTSET
# NOTSET -> NOTSET.
increase_verbosity()
assert get_level() == logging.NOTSET
def test_decrease_verbosity(self):
"""Make sure decrease_verbosity() respects default and custom levels."""
# Start from a known state.
set_level(logging.INFO)
assert get_level() == logging.INFO
# INFO -> NOTICE.
decrease_verbosity()
assert get_level() == logging.NOTICE
# NOTICE -> WARNING.
decrease_verbosity()
assert get_level() == logging.WARNING
# WARNING -> SUCCESS.
decrease_verbosity()
assert get_level() == logging.SUCCESS
# SUCCESS -> ERROR.
decrease_verbosity()
assert get_level() == logging.ERROR
# ERROR -> CRITICAL.
decrease_verbosity()
assert get_level() == logging.CRITICAL
def setUp(self):
"""Reset logging verbosity before each test."""
coloredlogs.set_level(logging.INFO)
def test_is_verbose(self):
"""Make sure is_verbose() does what it should :-)."""
set_level(logging.INFO)
assert not is_verbose()
set_level(logging.DEBUG)
assert is_verbose()
set_level(logging.VERBOSE)
assert is_verbose()
action="store_true",
default=False,
help="allow the supplied field to change types if already specified",
)
config_set_parser.set_defaults(func=set_configuration_option)
args = parser.parse_args()
if args.colorize == "never":
coloredlogs.DEFAULT_LEVEL_STYLES = {}
coloredlogs.DEFAULT_FIELD_STYLES = {}
coloredlogs.install()
if args.debug:
coloredlogs.set_level(logging.DEBUG)
try:
if "func" in args:
args.func(args)
else:
parser.print_help()
except FatalException:
exit(1)
def __enter__(self):
"""Customize the logging verbosity when entering the :keyword:`with` block."""
if self.original_level is None:
self.original_level = get_level()
set_level(self.level)