From 5cf7d1dba21b51d4d20dc61b5a2f50bf5fc4fbf0 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 18 Aug 2018 11:36:24 -0300 Subject: [PATCH] "suspend" method of capture fixture private Also change the context-manager to global_and_fixture_disabled to better convey its meaning --- src/_pytest/capture.py | 13 +++++++------ src/_pytest/logging.py | 2 +- testing/logging/test_reporting.py | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index 4bf979efc..c84ba825e 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -122,11 +122,11 @@ class CaptureManager(object): return outerr @contextlib.contextmanager - def disabled(self): - """Context manager to temporarily disables capture.""" + def global_and_fixture_disabled(self): + """Context manager to temporarily disables global and current fixture capturing.""" # Need to undo local capsys-et-al if exists before disabling global capture fixture = getattr(self._current_item, "_capture_fixture", None) - ctx_manager = fixture.suspend() if fixture else dummy_context_manager() + ctx_manager = fixture._suspend() if fixture else dummy_context_manager() with ctx_manager: self.suspend_global_capture(item=None, in_=False) try: @@ -333,8 +333,8 @@ class CaptureFixture(object): return self._outerr @contextlib.contextmanager - def suspend(self): - """Temporarily disables capture while inside the 'with' block.""" + def _suspend(self): + """Suspends this fixture's own capturing temporarily.""" self._capture.suspend_capturing() try: yield @@ -343,8 +343,9 @@ class CaptureFixture(object): @contextlib.contextmanager def disabled(self): + """Temporarily disables capture while inside the 'with' block.""" capmanager = self.request.config.pluginmanager.getplugin("capturemanager") - with capmanager.disabled(): + with capmanager.global_and_fixture_disabled(): yield diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index 5b0fcd693..c9c65c4c1 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -569,7 +569,7 @@ class _LiveLoggingStreamHandler(logging.StreamHandler): def emit(self, record): ctx_manager = ( - self.capture_manager.disabled() + self.capture_manager.global_and_fixture_disabled() if self.capture_manager else dummy_context_manager() ) diff --git a/testing/logging/test_reporting.py b/testing/logging/test_reporting.py index ed89f5b7a..820295886 100644 --- a/testing/logging/test_reporting.py +++ b/testing/logging/test_reporting.py @@ -885,7 +885,7 @@ def test_live_logging_suspends_capture(has_capture_manager, request): calls = [] @contextlib.contextmanager - def disabled(self): + def global_and_fixture_disabled(self): self.calls.append("enter disabled") yield self.calls.append("exit disabled")