def test_fixture_use_by_other_fixtures_teardown(
        self, pytester: Pytester, cap
    ) -> None:
        """Ensure we can access setup and teardown buffers from teardown when using capsys/capfd (##3033)"""
        pytester.makepyfile(
            f"""\
            import sys
            import pytest
            import os

            @pytest.fixture()
            def fix({cap}):
                print("setup out")
                sys.stderr.write("setup err\\n")
                yield
                out, err = {cap}.readouterr()
                assert out == 'setup out\\ncall out\\n'
                assert err == 'setup err\\ncall err\\n'

            def test_a(fix):
                print("call out")
                sys.stderr.write("call err\\n")
        """
        )
        reprec = pytester.inline_run()
        reprec.assertoutcome(passed=1)
Ensure we can access setup and teardown buffers from teardown when using capsys/capfd (##3033)
testing/test_capture.py