Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show full Python Traceback with Tox/Py.test

Tags:

python

pytest

tox

I'm using tox and py.test to run my Python unittests, and even though I'm using py.test's --tb=long option, errors are showing like:

E   ConftestImportFailure: (local('/myproject/tests/functional_tests/conftest.py'), (<type 'exceptions.ImportError'>, ImportError('No module named blah',), <traceback object at 0x7fb5bb740518>))

Tox is running the command:

py.test -rxs -rf -rs --ff --tb=long -x -k testname

How do I make is show the full traceback? I can't find anything mentioning this in the docs besides the --tb option.

like image 940
Cerin Avatar asked Apr 15 '16 18:04

Cerin


People also ask

Which command can be used to show all available fixtures?

Additionally, if you wish to display a list of fixtures for each test, try the --fixtures-per-test flag.

How do I run pytest in verbose mode?

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

How do I fix Python traceback error?

The traceback error also shows the type of error and information about that error. The above case is IndexError: list index out of range . You can fix it using the valid index number to retrieve an item from a list.


1 Answers

For pytest, you can use py.test --tb=native to switch to the full/native Python tracebacks.

See pytest documentation on tracebacks.

like image 76
bluenote10 Avatar answered Oct 18 '22 08:10

bluenote10