Merge pull request #3045 from thisch/revert_accidental_push
Revert accidental push
This commit is contained in:
commit
30729b7c3c
|
@ -5,7 +5,6 @@ from contextlib import closing, contextmanager
|
|||
import sys
|
||||
import six
|
||||
|
||||
import _pytest
|
||||
import pytest
|
||||
import py
|
||||
|
||||
|
@ -77,9 +76,6 @@ def pytest_addoption(parser):
|
|||
'--log-file-date-format',
|
||||
dest='log_file_date_format', default=DEFAULT_LOG_DATE_FORMAT,
|
||||
help='log date format as used by the logging module.')
|
||||
add_option_ini(
|
||||
'--capture-log', choices=['on-failure', 'off', 'live'],
|
||||
dest='capture_log', default='on-failure')
|
||||
|
||||
|
||||
@contextmanager
|
||||
|
@ -121,17 +117,6 @@ class LogCaptureHandler(logging.StreamHandler):
|
|||
logging.StreamHandler.emit(self, record)
|
||||
|
||||
|
||||
class TerminalReporterHandler(logging.Handler):
|
||||
def __init__(self, reporter):
|
||||
self.reporter = reporter
|
||||
super(TerminalReporterHandler, self).__init__()
|
||||
|
||||
def emit(self, record):
|
||||
# FIXME: I don't get any output with the reporter obj
|
||||
# self.reporter.write(self.format(record))
|
||||
print(self.format(record))
|
||||
|
||||
|
||||
class LogCaptureFixture(object):
|
||||
"""Provides access and control of log capturing."""
|
||||
|
||||
|
@ -256,8 +241,6 @@ class LoggingPlugin(object):
|
|||
The formatter can be safely shared across all handlers so
|
||||
create a single one for the entire test session here.
|
||||
"""
|
||||
self.capture_log = get_option_ini(config, 'capture_log')
|
||||
|
||||
self.log_cli_level = get_actual_log_level(
|
||||
config, 'log_cli_level', 'log_level') or logging.WARNING
|
||||
|
||||
|
@ -266,15 +249,18 @@ class LoggingPlugin(object):
|
|||
get_option_ini(config, 'log_format'),
|
||||
get_option_ini(config, 'log_date_format'))
|
||||
|
||||
log_cli_handler = logging.StreamHandler(sys.stderr)
|
||||
log_cli_format = get_option_ini(
|
||||
config, 'log_cli_format', 'log_format')
|
||||
log_cli_date_format = get_option_ini(
|
||||
config, 'log_cli_date_format', 'log_date_format')
|
||||
self.log_cli_formatter = logging.Formatter(
|
||||
log_cli_formatter = logging.Formatter(
|
||||
log_cli_format,
|
||||
datefmt=log_cli_date_format)
|
||||
|
||||
self.reporter = _pytest.config.create_terminal_writer(config, sys.stdout)
|
||||
self.log_cli_handler = log_cli_handler # needed for a single unittest
|
||||
self.live_logs = catching_logs(log_cli_handler,
|
||||
formatter=log_cli_formatter,
|
||||
level=self.log_cli_level)
|
||||
|
||||
log_file = get_option_ini(config, 'log_file')
|
||||
if log_file:
|
||||
|
@ -299,10 +285,6 @@ class LoggingPlugin(object):
|
|||
@contextmanager
|
||||
def _runtest_for(self, item, when):
|
||||
"""Implements the internals of pytest_runtest_xxx() hook."""
|
||||
if self.capture_log != 'on-failure':
|
||||
yield
|
||||
return
|
||||
|
||||
with catching_logs(LogCaptureHandler(),
|
||||
formatter=self.formatter) as log_handler:
|
||||
item.catch_log_handler = log_handler
|
||||
|
@ -334,19 +316,7 @@ class LoggingPlugin(object):
|
|||
@pytest.hookimpl(hookwrapper=True)
|
||||
def pytest_runtestloop(self, session):
|
||||
"""Runs all collected test items."""
|
||||
|
||||
if self.capture_log == 'live':
|
||||
with catching_logs(TerminalReporterHandler(self.reporter),
|
||||
formatter=self.log_cli_formatter,
|
||||
level=self.log_cli_level):
|
||||
if self.log_file_handler is not None:
|
||||
with closing(self.log_file_handler):
|
||||
with catching_logs(self.log_file_handler,
|
||||
level=self.log_file_level):
|
||||
yield # run all the tests
|
||||
else:
|
||||
yield # run all the tests
|
||||
elif self.capture_log == 'on-failure':
|
||||
with self.live_logs:
|
||||
if self.log_file_handler is not None:
|
||||
with closing(self.log_file_handler):
|
||||
with catching_logs(self.log_file_handler,
|
||||
|
@ -354,7 +324,3 @@ class LoggingPlugin(object):
|
|||
yield # run all the tests
|
||||
else:
|
||||
yield # run all the tests
|
||||
elif self.capture_log == 'off':
|
||||
yield
|
||||
else:
|
||||
raise ValueError('capture_log: %s' % capture_log)
|
||||
|
|
Loading…
Reference in New Issue