pytest-dev / pytest-dev/pytest

The colors of the logs are not displayed using --capture=tee-sys

Open
#11,270 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

plugin: capture plugin: logging type: enhancement
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

  • a detailed description of the bug or problem you are having:

When I use --capture=tee-sys instead of -s the logs are not colored anymore. Example:
image

The source of the issue is that I want to capture to logs to put them in an HTML report, but I also want to see live what is going on in the test as it takes a long time to execute and I need to check the progress. Not having the colors makes it harder to read.

  • output of pip list from the virtual environment you are using
colorama==0.4.6
exceptiongroup==1.1.2
iniconfig==2.0.0     
loguru==0.7.0        
packaging==23.1      
pluggy==1.2.0        
pytest==7.4.0        
tomli==2.0.1
win32-setctime==1.1.0
  • pytest and operating system versions
Windows 10:
Python 3.10.10
  • minimal example if possible:
"""
My test module
"""
from loguru import logger


def test_color():
    """
    My test
    """
    logger.info("My colored log")

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the minimal Python test with Loguru on Windows using --capture=tee-sys and compare it with -s. Trace pytest's tee-sys capture path and determine why colored log output is removed while being displayed. Done means the logs remain colored in the live terminal and are still captured for the HTML report.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.