Small cleanups on _pytest.compat

Small improvements and cleanups
This commit is contained in:
Bruno Oliveira
2019-06-15 10:06:37 -03:00
parent 240828d912
commit 355eb5adfb
5 changed files with 25 additions and 30 deletions

View File

@@ -6,7 +6,7 @@ from contextlib import contextmanager
import py
import pytest
from _pytest.compat import dummy_context_manager
from _pytest.compat import nullcontext
from _pytest.config import create_terminal_writer
from _pytest.pathlib import Path
@@ -436,7 +436,7 @@ class LoggingPlugin:
self.log_cli_handler = None
self.live_logs_context = lambda: dummy_context_manager()
self.live_logs_context = lambda: nullcontext()
# Note that the lambda for the live_logs_context is needed because
# live_logs_context can otherwise not be entered multiple times due
# to limitations of contextlib.contextmanager.
@@ -676,7 +676,7 @@ class _LiveLoggingStreamHandler(logging.StreamHandler):
ctx_manager = (
self.capture_manager.global_and_fixture_disabled()
if self.capture_manager
else dummy_context_manager()
else nullcontext()
)
with ctx_manager:
if not self._first_record_emitted: