Making conftest import failures easier to debug

This commit is contained in:
Javier Domingo Cansino 2016-07-05 09:56:54 +01:00
parent 7927dff8a1
commit 61e605f60b
3 changed files with 8 additions and 1 deletions

View File

@ -59,6 +59,7 @@ Jaap Broekhuizen
Jan Balster
Janne Vanhala
Jason R. Coombs
Javier Domingo Cansino
John Towler
Joshua Bronson
Jurko Gospodnetić

View File

@ -14,7 +14,7 @@
level an error will be raised during collection.
Thanks `@omarkohl`_ for the complete PR (`#1519`_).
*
* Fix (`1516`_): ConftestImportFailure now shows the traceback
**Incompatible changes**

View File

@ -25,6 +25,12 @@ class ConftestImportFailure(Exception):
self.path = path
self.excinfo = excinfo
def __str__(self):
etype, evalue, etb = self.excinfo
formatted = traceback.format_tb(etb)
# The level of the tracebacks we want to print is hand crafted :(
return repr(evalue) + '\n' + ''.join(formatted[2:])
def main(args=None, plugins=None):
""" return exit code, after performing an in-process test run.