简体   繁体   中英

PyCharm duplicated py.test tests assertions

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

在此输入图像描述

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 .

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.

在此输入图像描述

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

在此输入图像描述

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM