From f4d3ec6370f5855637d13853bad920e34e914fc0 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 30 Nov 2018 23:04:59 +0000 Subject: [PATCH 1/2] Logging done late enough might happen when capture already stopped. --- src/_pytest/capture.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index ec72ae3ec..376b4f87b 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -117,7 +117,10 @@ class CaptureManager(object): self._global_capturing = None def resume_global_capture(self): - self._global_capturing.resume_capturing() + # During teardown of the python process, and on rare occasions, capture + # attributes can be `None` while trying to resume global capture. + if self._global_capturing is not None: + self._global_capturing.resume_capturing() def suspend_global_capture(self, in_=False): cap = getattr(self, "_global_capturing", None) From f792cc420c302109011bb47c0f5103c468d957ac Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sat, 1 Dec 2018 19:11:02 +0000 Subject: [PATCH 2/2] Add changelog entry --- changelog/4487.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/4487.bugfix.rst diff --git a/changelog/4487.bugfix.rst b/changelog/4487.bugfix.rst new file mode 100644 index 000000000..3ba8d4731 --- /dev/null +++ b/changelog/4487.bugfix.rst @@ -0,0 +1 @@ +During teardown of the python process, and on rare occasions, capture attributes can be ``None`` while trying to resume global capture.