py.test
's --verbose
option is required to show full diffs on assertion failures, but this also displays the full name of each test during execution (which is noisy).
I'd like full diffs to show when an assertion fails, but I only want single .
's to appear when the tests are running. Is there a way to do this?
Running pytest -vv should make your output more verbose. If you want your output to be less verbose, try pytest -q or pytest --quiet .
Verbosity. The -v flag controls the verbosity of pytest output in various aspects: test session progress, assertion details when tests fail, fixtures details with --fixtures , etc.
conftest.py is where you setup test configurations and store the testcases that are used by test functions. The configurations and the testcases are called fixture in pytest. The test_*. py files are where the actual test functions reside.
Unfortunately, there seems to be no configuration or command line flag for that, since that's hard-coded deep inside pytest: when you define --verbose
, you get the whole package. However, I've managed to come up with this hackish hack. Put the following function into your conftest.py
:
def pytest_configure(config):
terminal = config.pluginmanager.getplugin('terminal')
BaseReporter = terminal.TerminalReporter
class QuietReporter(BaseReporter):
def __init__(self, *args, **kwargs):
BaseReporter.__init__(self, *args, **kwargs)
self.verbosity = 0
self.showlongtestinfo = self.showfspath = False
terminal.TerminalReporter = QuietReporter
This is essentially a monkey-patching, relying on pytest internals, not guaranteed to be compatible with the future versions and ugly as sin. You can also make this patch conditional based on some other custom configuration of command-line argument.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With