From 9f7345d6639f803330835febee2694ceb925e08a Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 18 Aug 2018 11:08:03 -0300 Subject: [PATCH] Avoid leaving a reference to the last item on CaptureManager --- src/_pytest/capture.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index 606f7bdd9..bd0fb87f0 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -176,6 +176,7 @@ class CaptureManager(object): # be activated during pytest_runtest_call yield self.suspend_capture_item(item, "setup") + self._current_item = None @pytest.hookimpl(hookwrapper=True) def pytest_runtest_call(self, item): @@ -186,6 +187,7 @@ class CaptureManager(object): self.activate_fixture(item) yield self.suspend_capture_item(item, "call") + self._current_item = None @pytest.hookimpl(hookwrapper=True) def pytest_runtest_teardown(self, item): @@ -194,6 +196,7 @@ class CaptureManager(object): self.activate_fixture(item) yield self.suspend_capture_item(item, "teardown") + self._current_item = None @pytest.hookimpl(tryfirst=True) def pytest_keyboard_interrupt(self, excinfo):