CaptureFixture: do not crash in _suspend when not started

This happened in test_pdb_with_caplog_on_pdb_invocation.
This commit is contained in:
Daniel Hahler 2019-05-23 08:56:52 +02:00
parent a0ff5deabf
commit e0b584d048
1 changed files with 5 additions and 4 deletions

View File

@ -358,8 +358,7 @@ class CaptureFixture(object):
self._captured_err = self.captureclass.EMPTY_BUFFER
def _start(self):
# Start if not started yet
if getattr(self, "_capture", None) is None:
if self._capture is None:
self._capture = MultiCapture(
out=True, err=True, in_=False, Capture=self.captureclass
)
@ -389,11 +388,13 @@ class CaptureFixture(object):
def _suspend(self):
"""Suspends this fixture's own capturing temporarily."""
self._capture.suspend_capturing()
if self._capture is not None:
self._capture.suspend_capturing()
def _resume(self):
"""Resumes this fixture's own capturing temporarily."""
self._capture.resume_capturing()
if self._capture is not None:
self._capture.resume_capturing()
@contextlib.contextmanager
def disabled(self):