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

str(err) on pytest.raises does not yield the exception message any more #5528

Closed
mwouts opened this issue Jun 30, 2019 · 4 comments
Closed

Comments

@mwouts
Copy link

mwouts commented Jun 30, 2019

Thanks for working on this beautiful project!

I use pytest extensively to test a project of mine, and I find that pytest-5.0.0, in combination with Python 3.8.0b1+, does not give the exception message any more if I apply str(err) to an exception err captured with pytest.raises.

A few days ago I was using pytest-4.6.3 with the same version of Python 3.8 dev and had no such issue.

A code like this one should be enough to reproduce the issue:

def test_error_str():
    with pytest.raises(Exception) as err:
        raise Exception("message")

    assert "message" in str(err)

The full details of what happens in the context of my project are available at mwouts/jupytext#269.

@asottile
Copy link
Member

you want str(err.value)

this was intentionally changed in 5.0.0, see the changelog: https://pytest.readthedocs.io/en/latest/changelog.html#removals

#5412

mwouts added a commit to mwouts/jupytext that referenced this issue Jun 30, 2019
Access to exception message with str(info.value)
Cf. pytest-dev/pytest#5528

Fixes #269
@nicoddemus
Copy link
Member

Indeed!

It seems your question has been resolved so I'm closing this for now. Feel free to followup with further questions.

mwouts added a commit to mwouts/jupytext that referenced this issue Jun 30, 2019
@mwouts
Copy link
Author

mwouts commented Jun 30, 2019

Sure! I will update my tests to fix this. And many thanks for the quick response!

@asottile
Copy link
Member

btw, the reason you only hit this in python3.8 is it appears you're not actually installing pytest and just relying on travis's preinstalled version

mwouts added a commit to mwouts/jupytext that referenced this issue Jun 30, 2019
Access to exception message with str(info.value)
Cf. pytest-dev/pytest#5528

Fixes #269
mwouts added a commit to mwouts/jupytext that referenced this issue Jun 30, 2019
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

3 participants