4

I am running pytest with tavern for a small testing API project. Failing a test, throws me a bunch of verbose errors plus the response I am expecting to get (why it failed). How can I make pytest less verbose?

I tried pytest --tb=short, pytest -vv, pytest --tavern-beta-new-traceback and none worked as expected just telling me the reason it failed. Something like:

E   tavern.util.exceptions.TestFailError: Test 'Do something' failed:
    - Status code was 200, expected 300
-------------------------------------------------------- Captured log call --------------------------------------------------------
base.py                     41 ERROR    Status code was 200, expected 300
==================================================== 1 failed in 0.38 seconds =====================================================

Maybe is something wrong with how tavern handles errors or pytest?

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
Andrei B
  • 57
  • 2
  • 4
  • Having the same problem. I saw that [your issue](https://github.com/taverntesting/tavern/issues/354) was closed, saying that it's a pytest config problem but none of the command line options provided in the documention links work as intended. – Suzana Jun 19 '19 at 09:33

3 Answers3

5

Running pytest -vv should make your output more verbose. If you want your output to be less verbose, try pytest -q or pytest --quiet.

dotcomstar
  • 51
  • 1
  • 5
2

Sometimes using a higher log level might reduce the pytest output clutter. For example, using

pytest <my_test_folder> --log-cli-level=warning

Different options for log level (from most verbose to least verbose) are: debug, info, warning, error and critical.

Niko Föhr
  • 28,336
  • 10
  • 93
  • 96
0

You can change the verbosity of the output with --verbosity=VERBOSE below:

pytest --help
...
--verbosity=VERBOSE   Set verbosity. Default: 0.

So, --verbosity=1 below can get the output verbosely. *It is identical to -v and --verbose:

pytest --verbosity=1

And, --verbosity=0 below can get the output normally:

pytest --verbosity=0

--verbosity=-1 below can get the output less verbosely. *It is identical to -q and --quiet:

pytest --verbosity=-1
Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129