Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically attach to non-propagating loggers #10303

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Sep 16, 2022

  1. Automatically attach to non-propagating loggers

    Currently, pytest attaches its log handlers only to the root logger, and
    relies on log propagation to catch logs from loggers deeper in the
    hierarchy. In consequence we miss logs if one of those child loggers has
    logger.propagate set to False by user code. This affects caplog, report
    logging and live logging.
    
    This commit showcases a possible fix, where we attach not only to the
    root logger, but also to non-propagating loggers as they occur. To do so
    we patch the standard libraries logging module with our own descriptor
    that intercepts assignments to logger.propagate. This enables us to
    inject and remove our pytest handlers right on time, even during
    executing test calls, with neglible performance impact.
    
    Attempt to fix pytest-dev#3697.
    Tobias Deiminger committed Sep 16, 2022
    Configuration menu
    Copy the full SHA
    13a1f37 View commit details
    Browse the repository at this point in the history