def test_log_report_captures_according_to_config_option_upon_failure(
    pytester: Pytester,
) -> None:
    """Test that upon failure:
    (1) `caplog` succeeded to capture the DEBUG message and assert on it => No `Exception` is raised.
    (2) The `DEBUG` message does NOT appear in the `Captured log call` report.
    (3) The stdout, `INFO`, and `WARNING` messages DO appear in the test reports due to `--log-level=INFO`.
    """
    pytester.makepyfile(
        """
        import pytest
        import logging

        def function_that_logs():
            logging.debug('DEBUG log ' + 'message')
            logging.info('INFO log ' + 'message')
            logging.warning('WARNING log ' + 'message')
            print('Print ' + 'message')

        def test_that_fails(request, caplog):
            plugin = request.config.pluginmanager.getplugin('logging-plugin')
            assert plugin.log_level == logging.INFO

            with caplog.at_level(logging.DEBUG):
                function_that_logs()

            if 'DEBUG log ' + 'message' not in caplog.text:
                raise Exception('caplog failed to ' + 'capture DEBUG')

            assert False
    """
    )

    result = pytester.runpytest("--log-level=INFO")
    result.stdout.no_fnmatch_line("*Exception: caplog failed to capture DEBUG*")
    result.stdout.no_fnmatch_line("*DEBUG log message*")
    result.stdout.fnmatch_lines(
        ["*Print message*", "*INFO log message*", "*WARNING log message*"]
    )
    assert result.ret == 1
Test that upon failure:
    (1) `caplog` succeeded to capture the DEBUG message and assert on it => No `Exception` is raised.
    (2) The `DEBUG` message does NOT appear in the `Captured log call` report.
    (3) The stdout, `INFO`, and `WARNING` messages DO appear in the test reports due to `--log-level=INFO`.
    
testing/logging/test_fixture.py