@pytest.fixture(scope='function', autouse=True)
def reset_loggers():
    'Prevent logging handlers from capturing temporary file handles.\n\n    For example, a test that uses the `capsys` fixture and calls\n    `logging.exception()` will initialize logging with a default handler that\n    captures `sys.stderr`.  When the test ends, the file handles will be closed\n    and `sys.stderr` will be returned to its original handle, but the logging\n    will have a dangling reference to the temporary handle used in the `capsys`\n    fixture.\n\n    '
    logger = logging.getLogger()
    for handler in logger.handlers:
        logger.removeHandler(handler)
Prevent logging handlers from capturing temporary file handles.

For example, a test that uses the `capsys` fixture and calls
`logging.exception()` will initialize logging with a default handler that
captures `sys.stderr`.  When the test ends, the file handles will be closed
and `sys.stderr` will be returned to its original handle, but the logging
will have a dangling reference to the temporary handle used in the `capsys`
fixture.
@pytest.fixture(scope='function', autouse=True)
def reset_loggers():
    'Prevent logging handlers from capturing temporary file handles.\n\n    For example, a test that uses the `capsys` fixture and calls\n    `logging.exception()` will initialize logging with a default handler that\n    captures `sys.stderr`.  When the test ends, the file handles will be closed\n    and `sys.stderr` will be returned to its original handle, but the logging\n    will have a dangling reference to the temporary handle used in the `capsys`\n    fixture.\n\n    '
    logger = logging.getLogger()
    for handler in logger.handlers:
        logger.removeHandler(handler)