Merge pull request #1746 from pytest-dev/conftest-exception-printing
Conftest exception printing
This commit is contained in:
commit
eaa4ee3fdf
1
AUTHORS
1
AUTHORS
|
@ -61,6 +61,7 @@ Jaap Broekhuizen
|
||||||
Jan Balster
|
Jan Balster
|
||||||
Janne Vanhala
|
Janne Vanhala
|
||||||
Jason R. Coombs
|
Jason R. Coombs
|
||||||
|
Javier Domingo Cansino
|
||||||
John Towler
|
John Towler
|
||||||
Joshua Bronson
|
Joshua Bronson
|
||||||
Jurko Gospodnetić
|
Jurko Gospodnetić
|
||||||
|
|
|
@ -60,8 +60,6 @@ time or change existing behaviors in order to make them less surprising/more use
|
||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
*
|
|
||||||
|
|
||||||
**New Features**
|
**New Features**
|
||||||
|
|
||||||
* Support nose-style ``__test__`` attribute on methods of classes,
|
* Support nose-style ``__test__`` attribute on methods of classes,
|
||||||
|
@ -251,6 +249,10 @@ time or change existing behaviors in order to make them less surprising/more use
|
||||||
Thanks `@Vogtinator`_ for reporting and `@RedBeardCode`_ and
|
Thanks `@Vogtinator`_ for reporting and `@RedBeardCode`_ and
|
||||||
`@tomviner`_ for the PR.
|
`@tomviner`_ for the PR.
|
||||||
|
|
||||||
|
* ``ConftestImportFailure`` now shows the traceback making it easier to
|
||||||
|
identify bugs in ``conftest.py`` files (`#1516`_). Thanks `@txomon`_ for
|
||||||
|
the PR.
|
||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
*
|
*
|
||||||
|
@ -281,6 +283,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
||||||
.. _#1479: https://github.com/pytest-dev/pytest/issues/1479
|
.. _#1479: https://github.com/pytest-dev/pytest/issues/1479
|
||||||
.. _#1502: https://github.com/pytest-dev/pytest/pull/1502
|
.. _#1502: https://github.com/pytest-dev/pytest/pull/1502
|
||||||
.. _#1503: https://github.com/pytest-dev/pytest/issues/1503
|
.. _#1503: https://github.com/pytest-dev/pytest/issues/1503
|
||||||
|
.. _#1516: https://github.com/pytest-dev/pytest/pull/1516
|
||||||
.. _#1519: https://github.com/pytest-dev/pytest/pull/1519
|
.. _#1519: https://github.com/pytest-dev/pytest/pull/1519
|
||||||
.. _#1520: https://github.com/pytest-dev/pytest/pull/1520
|
.. _#1520: https://github.com/pytest-dev/pytest/pull/1520
|
||||||
.. _#1526: https://github.com/pytest-dev/pytest/pull/1526
|
.. _#1526: https://github.com/pytest-dev/pytest/pull/1526
|
||||||
|
@ -333,6 +336,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
||||||
.. _@sober7: https://github.com/sober7
|
.. _@sober7: https://github.com/sober7
|
||||||
.. _@tareqalayan: https://github.com/tareqalayan
|
.. _@tareqalayan: https://github.com/tareqalayan
|
||||||
.. _@taschini: https://github.com/taschini
|
.. _@taschini: https://github.com/taschini
|
||||||
|
.. _@txomon: https://github.com/txomon
|
||||||
|
|
||||||
2.9.2
|
2.9.2
|
||||||
=====
|
=====
|
||||||
|
|
|
@ -27,6 +27,12 @@ class ConftestImportFailure(Exception):
|
||||||
self.path = path
|
self.path = path
|
||||||
self.excinfo = excinfo
|
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):
|
def main(args=None, plugins=None):
|
||||||
""" return exit code, after performing an in-process test run.
|
""" return exit code, after performing an in-process test run.
|
||||||
|
|
|
@ -408,3 +408,16 @@ def test_issue1073_conftest_special_objects(testdir):
|
||||||
""")
|
""")
|
||||||
res = testdir.runpytest()
|
res = testdir.runpytest()
|
||||||
assert res.ret == 0
|
assert res.ret == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_conftest_exception_handling(testdir):
|
||||||
|
testdir.makeconftest('''
|
||||||
|
raise ValueError()
|
||||||
|
''')
|
||||||
|
testdir.makepyfile("""
|
||||||
|
def test_some():
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
res = testdir.runpytest()
|
||||||
|
assert res.ret == 4
|
||||||
|
assert 'raise ValueError()' in [line.strip() for line in res.errlines]
|
||||||
|
|
Loading…
Reference in New Issue