Skip to content

pytest results in VSCode should show logging. #21781

@PhilipMay

Description

@PhilipMay

I have a simple test:

import logging
LOGGER = logging.getLogger(__name__)
def test():
    a = 888
    LOGGER.info(">>>>>> Test1 <<<<<<<<<<<<< %s", a)
    assert False

I configuted pytest so it is logging at info level.
See pyproject.toml:

[tool.pytest.ini_options]
log_cli_level="INFO"

When I execute the test with pytest tests it shows this:


tests/test_log.py F                                                                                                                       [100%]

=================================================================== FAILURES ====================================================================
_____________________________________________________________________ test ______________________________________________________________________

    def test():
        a = 888
        LOGGER.info(">>>>>> Test1 <<<<<<<<<<<<< %s", a)
>       assert False
E       assert False

tests/test_log.py:9: AssertionError
--------------------------------------------------------------- Captured log call ---------------------------------------------------------------
INFO     tests.test_log:test_log.py:8 >>>>>> Test1 <<<<<<<<<<<<< 888
============================================================ short test summary info ============================================================
FAILED tests/test_log.py::test - assert False
=============================================================== 1 failed in 0.04s ===============================================================

Please not that it also shows the log output - which is this:
INFO tests.test_log:test_log.py:8 >>>>>> Test1 <<<<<<<<<<<<< 888.

I also want to see this logging output on the VSCode snippet that shows up at failed test functions. See screenshot:

But it is missing here:
image

Can you add the log output?

Metadata

Metadata

Assignees

Labels

area-testinginfo-neededIssue requires more information from postertriage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions