You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If some file in the import chain has an error (eg. importError) pytest will print :
UNEXPECTED EXCEPTION: ImportError('cannot import name bar',)
But I won't know where 'bar' is imported. I need the traceback.
So here is a patch in order for pytest to print the traceback. For example output would be :
#!python
016 >>> import foo
UNEXPECTED EXCEPTION: Traceback (most recent call last):
File "/usr/lib/python2.6/doctest.py", line 1253, in __run
compileflags, 1) in test.globs
File "<doctest test_baz.txt[0]>", line 1, in <module>
File "/path/to/code/foo/__init__.py", line 8, in <module>
from baz import x
File "/path/to/code/foo/baz.py", line 10, in <module>
from bar import so_important
ImportError: No module named bar
Activity
pytestbot commentedon May 28, 2011
Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):
fix issue43 - better tracebacks for unexpected exceptions in doctests
Merge pull request pytest-dev#43 from ahlmss/fix_unit_tests
Merge pull request pytest-dev#43 from manahl/fix-issue-42