Skip to content

No colors by default on GitHub Actions #7443

Closed
@The-Compiler

Description

@The-Compiler

When running pytest on GitHub Actions (like we do ourselves, random example), the output is not colored.

pytest does color output on Travis CI by default, so it could be argued that this is somehow GitHub Action's fault. However, other tools (e.g. eslint, and I think mypy) seem to colorize their output on GitHub actions just fine, without needing to force them! From what I've seen, those tools seem to be influenced by the TERM environment variable, while pytest's (or pylib's?) autodetection seems to work differently?

As a workaround, this helps (as part of the step definition):

      - name: "Run pytest"
        env:
          PYTEST_ADDOPTS: "--color=yes"
        run: pytest

(If you run pytest via tox, make sure to add PYTEST_ADDOPTS to passenv!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: enhancementnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions