Skip to content

Commit ecc5c84

Browse files
authored
Merge pull request #4487 from s0undt3ch/master
Logging done late enough might happen when capture already stopped.
2 parents d8e00c9 + f792cc4 commit ecc5c84

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

changelog/4487.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
During teardown of the python process, and on rare occasions, capture attributes can be ``None`` while trying to resume global capture.

src/_pytest/capture.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ def stop_global_capturing(self):
117117
self._global_capturing = None
118118

119119
def resume_global_capture(self):
120-
self._global_capturing.resume_capturing()
120+
# During teardown of the python process, and on rare occasions, capture
121+
# attributes can be `None` while trying to resume global capture.
122+
if self._global_capturing is not None:
123+
self._global_capturing.resume_capturing()
121124

122125
def suspend_global_capture(self, in_=False):
123126
cap = getattr(self, "_global_capturing", None)

0 commit comments

Comments
 (0)