How do I force pytest to write color output?

前端 未结 2 479
遥遥无期
遥遥无期 2021-02-02 07:31

How do I force pytest to show the results in color, even when writing to a pipe? There does not seem to be any command line option to do so.

2条回答
  •  有刺的猬
    2021-02-02 08:13

    The "py" library that pytest uses will not use color if it doesn't detect a terminal. I ended up making a change to it to allow setting an enviroment variable (PY_FORCE_COLOR=1) to force the color.

    I submitted a PR for this: https://bitbucket.org/hpk42/py/pull-request/10/add-an-environment-variable-py_force_color

    For now, I install my fork to do this:

    pip install hg+https://msabramo@bitbucket.org/msabramo/py@py_force_color

提交回复
热议问题