Skip to content Skip to sidebar Skip to footer

Making Pytest Quieter When Run From Pycharm

UPDATE: The messages shown below are NOT controlled by pytest various '-q' quiet options. They are coming from the TeamCity plugin... see my answer below. ORIGINAL: I have read th

Solution 1:

(see bottom for details for latest versions of PyCharm)

SOLUTION FOR PYCHARM 2018 Pycharm is silently installing a pytest plugin called TeamCity. It needs this plugin to track which tests succeed or fail. You can disable this loading of this plugin by editing the Pycharm runner script. (Yuck!)

On a Mac this file is located at: /Applications/PyCharm.app/Contents/helpers/pycharm/_jb_pytest_runner.py

Add the line as shown below to disable the loading of TeamCity:

...
jb_doc_args("pytest", args)
# We need to preparse numprocesses because user may set it using ini file
plugins_to_load = []    # <--- ADD THIS LINE TO AVOID TEAMCITY PLUGIN
config_result = real_prepare_config(args, plugins_to_load)
...
UPDATEFOR2019.3 andlater.On a Mac this file is located at:/Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm/_jb_pytest_runner.py...jb_doc_args("pytest",args)plugins_to_load= []    # ADDED THIS LINE TO AVOID EXTRA PYTEST PRINTING...

Solution 2:

Linux:

You can use: <your_command> >/dev/null. In this case the STDOUT will be redirected to /dev/null. It means if there is an error (STDERR) during running test, you will see it. If you want to suppress totally the output of pytest, you can use: <your_command> >/dev/null 2>&1. In this case the STDOUT and STDERR will be redirected to /dev/null

Example:

py.test test.py >/dev/null2>&1

Windows:

The situation is very similar in case of Windows OS. Only you can use NUL insted of /dev/null.

Example:

py.test test.py 2>&1 >NUL

Post a Comment for "Making Pytest Quieter When Run From Pycharm"