Terminal used by tests not behaving in docker container like as it does in local


I’m facing an strange problem where the docker container doesn’t behave in the same way when running locally than when running in the CI pipeline.
We use tox to test a python/django application.
The difference is in the output of some commands run by tox.
There are three tests that run django management commands, which are coloured.
So the matching test should include the characters for the colouring of the text, and this works when running the docker container locally and in CircleCI.
But for some reason, when the tests are run as part of the Gitlab CI pipeline the output is not coloured so the expected result doesn’t match the actual result.
As an example:
Expected: call(’\x1b[31;1mAborted.\x1b[0m’)
Actual: call(‘Aborted.’)

This seems to be due to how the container is run in the pipeline, but I can’t pinpoint the environment variables which determines that, if it’s even an environment variable.

Any ideas of why the text output of commands would be not coloured in the Gitlab CI deployment pipeline?


I have done some more investigation and it seems it’s due to the way the runner runs the container or the commands within it during the tests.
I’ve run the tox command manually inside the container used by gitlab to run the tests and it works.
The two options are that the gitlab runner does not run the container with a terminal supporting ANSI or that it pipes the output to another command.

Any ideas if it would be the terminal or the piping to another command?