I have bunch of executable running GTEST.
GTEST gives color output of passes and failes tests.
Now when I try to run bunch of executable using python subprocess.check_output script it is printing without color.
Here is code:
for root, dirs, files in os.walk(path):
for file in files:
try:
print subprocess.check_output([os.path.join(root, file)], shell= True, )
except subprocess.CalledProcessError, e:
error +=1
print error
Can anyone please help me, How I can print output as original output with colors?
Since I run in a similiar problem today on windows. I did a little resarch and it seems, that the problem is, that gtest creates the colors within the console by using the screenbuffer handles. The plain outstream of gtest does not contain any color information. That means that the color is lost as soon as these are redirected.
The following code worked for me:
subprocess.check_call(["cmd", "/c", gtest_case_executable, "--gtest_color=yes"])
as long as the Python command line call was not executed with any redirectioning calls like tee or >>.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With