Fix some coding-style issues in the logging plugin
This commit is contained in:
parent
8aed5fecd9
commit
af75ca435b
|
@ -24,7 +24,6 @@ def get_option_ini(config, *names):
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
"""Add options to control log capturing."""
|
"""Add options to control log capturing."""
|
||||||
|
|
||||||
group = parser.getgroup('logging')
|
group = parser.getgroup('logging')
|
||||||
|
|
||||||
def add_option_ini(option, dest, default=None, type=None, **kwargs):
|
def add_option_ini(option, dest, default=None, type=None, **kwargs):
|
||||||
|
@ -120,13 +119,11 @@ class LogCaptureHandler(logging.StreamHandler):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Creates a new log handler."""
|
"""Creates a new log handler."""
|
||||||
|
|
||||||
logging.StreamHandler.__init__(self, py.io.TextIO())
|
logging.StreamHandler.__init__(self, py.io.TextIO())
|
||||||
self.records = []
|
self.records = []
|
||||||
|
|
||||||
def emit(self, record):
|
def emit(self, record):
|
||||||
"""Keep the log records in a list in addition to the log text."""
|
"""Keep the log records in a list in addition to the log text."""
|
||||||
|
|
||||||
self.records.append(record)
|
self.records.append(record)
|
||||||
logging.StreamHandler.emit(self, record)
|
logging.StreamHandler.emit(self, record)
|
||||||
|
|
||||||
|
@ -288,8 +285,7 @@ class LoggingPlugin(object):
|
||||||
self.log_file_handler = logging.FileHandler(
|
self.log_file_handler = logging.FileHandler(
|
||||||
log_file,
|
log_file,
|
||||||
# Each pytest runtests session will write to a clean logfile
|
# Each pytest runtests session will write to a clean logfile
|
||||||
mode='w',
|
mode='w')
|
||||||
)
|
|
||||||
log_file_formatter = logging.Formatter(
|
log_file_formatter = logging.Formatter(
|
||||||
log_file_format,
|
log_file_format,
|
||||||
datefmt=log_file_date_format)
|
datefmt=log_file_date_format)
|
||||||
|
|
Loading…
Reference in New Issue