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

Test log: info and warning never show up #22335

Closed
aeschli opened this issue Oct 25, 2023 · 5 comments
Closed

Test log: info and warning never show up #22335

aeschli opened this issue Oct 25, 2023 · 5 comments
Assignees
Labels
area-testing info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team

Comments

@aeschli
Copy link

aeschli commented Oct 25, 2023

Testing #22291

class TestLogger(unittest.TestCase):
    def test_logging(self):
        logger = logging.getLogger(__name__)
        #logger.setLevel(logging.DEBUG)  # Set the desired log level
        logger.setLevel(logging.INFO)  # Set the desired log level

        logger.debug("This is a debug message in a unittest.")
        logger.info("This is an info message in a unittest.")
        logger.warning("This is a warning message in a unittest.")
        logger.error("This is an error message in a unittest.")
        logger.critical("This is a critical message in a unittest.")

        # Printing to stdout and stderr
        print("This is a stdout message.")
        print("This is a stderr message.", file=sys.stderr)

Regardless of log level, logger.debug and logger.info never show up in the Python test log. Is that expected?

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Oct 25, 2023
@eleanorjboyd
Copy link
Member

hm yes I am able to repro, will investigate! Thanks

@Bjoernolav
Copy link

Running v2023.20.0, I see a similar behavior. stderr and warning appears in the "Test result" ouput, but not on the specific tests. Would be very nice to get the output on the specific tests.

Example:

import warnings
import sys


def test_that_fails():
    warnings.warn('Looks like something might be wrong...')
    sys.stderr.write('Some stderr output indicating problems\n')
    assert False

Output showing the "Test result output", which includes stderr and warnings:
image

Output of the specific test that does not show stderr and warnings:
image

@eleanorjboyd
Copy link
Member

Hi @Bjoernolav thank you for your comment! Currently this is not possible as a functionality. Pytest does not tie output printed to stdout to the given test which produced it. Therefore we are unable to take the given output and say it is due to a specific test without running each test individually and awaiting all output responses which would be contrary to the how pytest designed it. Sorry!

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Nov 27, 2023
@eleanorjboyd
Copy link
Member

Hi @Bjoernolav, I was mistaken before and I can correlate specific output to a given test. I created an issue for this feature request which you can find here: #22594. Please upvote to demonstrate interest as this will help prioritize it. Thanks

Copy link

github-actions bot commented Jan 6, 2024

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.

Happy Coding!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants