Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

py.test console output in Jenkins

Jenkins console output from jobs running py.test tests contains unexpected characters "[1m" "[0m" like

[1m============== test session starts ==============[0m

Apparently these characters are leftovers from py.test output formatting ("test session starts" shows up as bold and colored in a terminal window). Is there a way to disable the output formatting? py.test's "--color no" option is not enough.

like image 843
glagolig Avatar asked Oct 31 '25 23:10

glagolig


1 Answers

In my case I'm running the pytest inside a docker by suing Jenkins descriptive pipeline, so need to verify several things:

First, add ansiColor to the options

pipeline {
...
    options {
        ansiColor('xterm')
        ...
    }
...
}

Second, verify that you added the docker run command the flag -t

-t : Allocate a pseudo-tty

for docker-compose it's tty: true

Third, you can force colorize by adding --color=yes to the pytest command python -m pytest --color=yes ...

--color=color color terminal output (yes/no/auto).

like image 66
dsaydon Avatar answered Nov 03 '25 14:11

dsaydon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!