PyCharm duplicated py.test tests assertions

Viewed 206

Everything works fine with PyCharm and pytest, except if I have failing tests, then it duplicates the error output:

enter image description here

One of actual failures if the red one and other is white. This is really annoys, and I haven't found any way to disable such behaviour.

There is an option to disable log via py.test, however it will disable all logging.

Note: everything works as expected if I run python -m pytest test.py.

2 Answers

I think that is a feature not a bug. The top level is being emitted during the testing which allows you to review the failure before the testing is complete. The second copy of the results is the summary which effectively removes any of the text that was showing test progress.

enter image description here

You can easily view just part of the test output by clicking on the test hierarchy:

enter image description here

The duplicated output can be elimited by running pytest with the -q or --quiet parameter.

You can configure the parameter to be applied to all PyCharm pytest tests by setting it in Edit Configurations --> Templates --> Python Tests --> pytest --> Additional Arguments.

This will then apply those arguments to all new run configurations. If you have a bunch of existing test run configurations, deleting all of them and then re-generating them by running a test or tests using the gutter icon is the quickest way to reset the output.

Related