Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When run under tox coloring is always disabled regardless --color flag #184

Closed
ssbarnea opened this issue Jun 18, 2018 · 2 comments
Closed

Comments

@ssbarnea
Copy link
Contributor

ssbarnea commented Jun 18, 2018

Issue description

I have being trying to make stestr to use coloring on output under tox but apparently it does not want to respect the --color flag.

When run outside tox, and mentioning --color, it works as expected. Even so, coloring is not enabled by default when user have interactive console, and it should be, just like other tools (including tox).

Steps to reproduce the problem

Use stester run --color inside tox.ini.

System information

stestr version (stestr --version):
2.1.0

Python release (python --version):
py27

pip packages (pip freeze):

Additional information

@mtreinish
Copy link
Owner

I'm not sure if there is anything we can do here in the stestr for this case. I was able to reproduce this in tox, and I added some print statements to stestr to find why the color was being printed. The underlying issue is when we call the curses module from stdlib to setup the colors at https://github.com/mtreinish/stestr/blob/master/stestr/colorizer.py#L71 it raises an error:

setupterm: could not find terminfo database

Which probably means that tox is not passing through $TERM from your terminal to the commands it's running. This is preventing the color from being set by stestr when it's writing to stdout and it falls back to not using color.

As for the color being enabled by default. I feel like this is one of those places where different people will have different preferences. Which is why it's an option in the user config file, so if you prefer to have color on by default (it will still fallback if it can't use it) you can just set that in your user config file:
https://stestr.readthedocs.io/en/latest/MANUAL.html#user-config-files

@mtreinish
Copy link
Owner

Yeah, I just confirmed that this can work with tox. You just need to add passenv=TERM in the testenv in your tox.ini (or set TOX_TESTENV_PASSENV=TERM in your env when you run tox), Otherwise tox will not pass through the $TERM env variable and the curses module won't be able to figure out what terminal is in use.

I'm going to mark this is as closed because I don't see anything we can do to fix this from stestr itself. Feel free to re-open if I'm missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants