Skip to content

Commit 61e605f

Browse files
committed
Making conftest import failures easier to debug
1 parent 7927dff commit 61e605f

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Jaap Broekhuizen
5959
Jan Balster
6060
Janne Vanhala
6161
Jason R. Coombs
62+
Javier Domingo Cansino
6263
John Towler
6364
Joshua Bronson
6465
Jurko Gospodnetić

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
level an error will be raised during collection.
1515
Thanks `@omarkohl`_ for the complete PR (`#1519`_).
1616

17-
*
17+
* Fix (`1516`_): ConftestImportFailure now shows the traceback
1818

1919
**Incompatible changes**
2020

_pytest/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ def __init__(self, path, excinfo):
2525
self.path = path
2626
self.excinfo = excinfo
2727

28+
def __str__(self):
29+
etype, evalue, etb = self.excinfo
30+
formatted = traceback.format_tb(etb)
31+
# The level of the tracebacks we want to print is hand crafted :(
32+
return repr(evalue) + '\n' + ''.join(formatted[2:])
33+
2834

2935
def main(args=None, plugins=None):
3036
""" return exit code, after performing an in-process test run.

0 commit comments

Comments
 (0)