Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest does not print chained exception for python 3 #1278

Closed
jettify opened this issue Dec 24, 2015 · 1 comment
Closed

pytest does not print chained exception for python 3 #1278

jettify opened this issue Dec 24, 2015 · 1 comment

Comments

@jettify
Copy link

jettify commented Dec 24, 2015

py.test pytest (2.8.5) does not print chained exceptions, data located in e.__cause__ and e.__context__.

If I execute this little script using python3 (python3 test_exception.py):

def test_x():
    try:
        raise KeyError
    except Exception as e:
        raise RuntimeError from e

if __name__ == '__main__':
    test_x()

I get:

Traceback (most recent call last):
  File "py_test.py", line 4, in test_x
    raise KeyError
KeyError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "py_test.py", line 9, in <module>
    test_x()
  File "py_test.py", line 6, in test_x
    raise RuntimeError from e
RuntimeError

in case of py.test (py.test test_exception.py):

    def test_x():
        try:
            raise KeyError
        except Exception as e:
>           raise RuntimeError from e
E           RuntimeError

py_test.py:6: RuntimeError
@nicoddemus
Copy link
Member

Thanks @jettify!

Closing as a duplicate of #138 though.

This should be tackled soon, because what was blocking this issue was #103, which is a working in progress at #1199.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants