Fixes issue #11314 -
This commit is contained in:
parent
6c2feb75d2
commit
d9697395d0
|
@ -303,13 +303,13 @@ def pytest_addoption(parser: Parser) -> None:
|
|||
add_option_ini(
|
||||
"--log-file-format",
|
||||
dest="log_file_format",
|
||||
default=DEFAULT_LOG_FORMAT,
|
||||
default=None,
|
||||
help="Log format used by the logging module",
|
||||
)
|
||||
add_option_ini(
|
||||
"--log-file-date-format",
|
||||
dest="log_file_date_format",
|
||||
default=DEFAULT_LOG_DATE_FORMAT,
|
||||
default=None,
|
||||
help="Log date format used by the logging module",
|
||||
)
|
||||
add_option_ini(
|
||||
|
@ -635,7 +635,9 @@ class LoggingPlugin:
|
|||
self.report_handler.setFormatter(self.formatter)
|
||||
|
||||
# File logging.
|
||||
self.log_file_level = get_log_level_for_setting(config, "log_file_level")
|
||||
self.log_file_level = get_log_level_for_setting(
|
||||
config, "log_file_level", "log_level"
|
||||
)
|
||||
log_file = get_option_ini(config, "log_file") or os.devnull
|
||||
if log_file != os.devnull:
|
||||
directory = os.path.dirname(os.path.abspath(log_file))
|
||||
|
|
|
@ -77,14 +77,14 @@ def test_root_logger_affected(pytester: Pytester) -> None:
|
|||
assert "warning text going to logger" not in stdout
|
||||
assert "info text going to logger" not in stdout
|
||||
|
||||
# The log file should contain the warning and the error log messages and
|
||||
# not the info one, because the default level of the root logger is
|
||||
# WARNING.
|
||||
# The log file should only contain the error log messages and
|
||||
# not the warning or info ones, because the root logger is set to
|
||||
# ERROR using --log-level=ERROR.
|
||||
assert os.path.isfile(log_file)
|
||||
with open(log_file, encoding="utf-8") as rfh:
|
||||
contents = rfh.read()
|
||||
assert "info text going to logger" not in contents
|
||||
assert "warning text going to logger" in contents
|
||||
assert "warning text going to logger" not in contents
|
||||
assert "error text going to logger" in contents
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue