From 26ef0684fc2f64ecdb5843379fc239970ab823da Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 15 Dec 2023 16:20:08 -0800 Subject: [PATCH] need to run last as pytest_runtest_call, since it starts capturing --- conftest.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/conftest.py b/conftest.py index 0ca5fed892..acb1a81c86 100644 --- a/conftest.py +++ b/conftest.py @@ -12,10 +12,15 @@ def pytest_sessionstart(session): session.config.option.randomly_reorganize = False -@pytest.fixture(scope="function", autouse=True) -def nocapture_fixture(caplog): - # print("nocapture_fixture") - with caplog.at_level(logging.CRITICAL + 1): +@pytest.hookimpl(hookwrapper=True, trylast=True) +def pytest_runtest_call(item): + # ensure we run as a hook after capturemanager's + capmanager = item.config.pluginmanager.getplugin("capturemanager") + + if item.get_closest_marker("nocapture") is not None: + with capmanager.global_and_fixture_disabled(): + yield + else: yield