Issue #353 duplicate

py.test doesn't expose that an exception occurred while handling another

Dun Peal avatarDun Peal created an issue
$ cat foo.py 
def test_report():
    try:
        raise RuntimeError('foo')
    except RuntimeError:
        raise RuntimeError('bar')

if __name__ == '__main__': test_report()
$ python foo.py 
Traceback (most recent call last):
  File "foo.py", line 3, in test_report
    raise RuntimeError('foo')
RuntimeError: foo

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "foo.py", line 7, in <module>
    if __name__ == '__main__': test_report()
  File "foo.py", line 5, in test_report
    raise RuntimeError('bar')
RuntimeError: bar
$ py.test foo.py 
============================= test session starts ==============================
platform linux -- Python 3.3.1 -- pytest-2.3.5
plugins: xdist
collected 1 items 

foo.py F

=================================== FAILURES ===================================
_________________________________ test_report __________________________________

    def test_report():
        try:
            raise RuntimeError('foo')
        except RuntimeError:
>           raise RuntimeError('bar')
E           RuntimeError: bar

foo.py:5: RuntimeError
=========================== 1 failed in 0.01 seconds ===========================

Comments (1)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.