fresh-cat-90827
05/03/2024, 1:55 PMpytest
run? Has anyone been successful in disabling colored output from pytest
? ๐งตfresh-cat-90827
05/03/2024, 1:55 PM$ pytest --color=no helloworld/greet/greeting_test.py
=================================================================================================== test session starts ====================================================================================================
platform linux -- Python 3.11.3, pytest-7.4.0, pluggy-1.2.0
rootdir: /home/alexey.tereshenkov/code/example-python
plugins: vcr-1.0.2
collected 1 item
helloworld/greet/greeting_test.py . [100%]
==================================================================================================== 1 passed in 0.05s =====================================================================================================
Attempt to disable colors (colors are still shown)
$ pants --pytest-args="--color=no" test --debug ::
=================================================================================================== test session starts ====================================================================================================
platform linux -- Python 3.9.17, pytest-7.0.1, pluggy-1.0.0
rootdir: /tmp/pants-sandbox-cMkXEZ
plugins: cov-3.0.0, xdist-2.5.0, forked-1.6.0
collected 1 item
helloworld/greet/greeting_test.py . [100%]
==================================================================================================== 1 passed in 0.04s =====================================================================================================
=================================================================================================== test session starts ====================================================================================================
platform linux -- Python 3.9.17, pytest-7.0.1, pluggy-1.0.0
rootdir: /tmp/pants-sandbox-40b0vG
plugins: cov-3.0.0, xdist-2.5.0, forked-1.6.0
collected 3 items
helloworld/translator/translator_test.py ... [100%]
==================================================================================================== 3 passed in 0.01s =====================================================================================================
I can see that the option is passed to the pytest runner in Pants:
$ pants --pytest-args="--color=foo" test ::
14:52:46.09 [WARN] Failed to generate JUnit XML data for helloworld/greet/greeting_test.py:tests.
14:52:46.09 [ERROR] Completed: Run Pytest - helloworld/greet/greeting_test.py:tests - failed (exit code 4).
ERROR: usage: pex [options] [file_or_dir] [file_or_dir] [...]
pex: error: argument --color: invalid choice: 'foo' (choose from 'yes', 'no', 'auto')
14:52:46.11 [WARN] Failed to generate JUnit XML data for helloworld/translator/translator_test.py:tests.
14:52:46.11 [ERROR] Completed: Run Pytest - helloworld/translator/translator_test.py:tests - failed (exit code 4).
ERROR: usage: pex [options] [file_or_dir] [file_or_dir] [...]
pex: error: argument --color: invalid choice: 'foo' (choose from 'yes', 'no', 'auto')
โ helloworld/greet/greeting_test.py:tests failed in 0.12s.
โ helloworld/translator/translator_test.py:tests failed in 0.13s.
square-psychiatrist-19087
05/03/2024, 2:53 PMpants --no-colors --pytest-args="--color=no" test ::
broad-processor-92400
05/05/2024, 11:12 PM