'Why is iTerm2 printing Pytest results in color?
I was playing around with Pytest --color=yes option and realized that my Terminal is printing results in color even without it being set.
Why is that?
My terminal setup is this:
- OS: MacOS
- iTerm2 build 3.4.15
- iTerm2 Report terminal type property set to: xterm-256color
- default shell is zsh (oh-my-zsh)
- not sure if anything else matters...
My guess is it has something to do with oh-my-zsh, but I am not sure what, where and how.
I got to this question because I was trying to create SublimeText build system that will print results in colors, without success (not counting using SublimeANSI plugin which works with some quirks).
So, to reiterate the question: I am confused why my terminal app is printing Pytest results in color, even when no --color=yes is not set for Pytest.
Solution 1:[1]
If we look at the Pytest terminal source, we'll see the following on the color option:
group._addoption(
"--color",
metavar="color",
action="store",
dest="color",
default="auto",
choices=["yes", "no", "auto"],
help="color terminal output (yes/no/auto).",
)
So the default is set to auto.
Your zsh/oh-my-zsh allows to use the colors and therefore there shown without passing the option yourself.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | 0stone0 |
