We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When you develop libraries, you often need to check that your library raises some exception at runtime.
I created better-devtools (Samuel Colvin's devtools fork) to automate this process and I would like to propose a similar tool for snapshot.
It would allow for something like the following syntax:
with snapshot(): raise ValueError
Which would translate into something like the following:
with snapshot(pytest.raises(ValueError)): raise ValueError
The text was updated successfully, but these errors were encountered:
I use something like this in my own tests.
def test_with(): with raises(snapshot("ZeroDivisionError: division by zero")): print(1/0)
the implementation looks like this:
@contextlib.contextmanager def raises(snapshot): with pytest.raises(Exception) as excinfo: yield assert f"{type(excinfo.value).__name__}: {excinfo.value}" == snapshot
would this fit your needs? I could put such generic utils in a inline_snapshot.extras module.
inline_snapshot.extras
Sorry, something went wrong.
Yup, it would! Looks great! You really did think of all use cases.
This is an amazing project.
That is very cool. I think I've had times where I would have used this, and it didn't occur to me that vanilla snapshot could do the trick.
snapshot
external
No branches or pull requests
When you develop libraries, you often need to check that your library raises some exception at runtime.
I created better-devtools (Samuel Colvin's devtools fork) to automate this process and I would like to propose a similar tool for snapshot.
It would allow for something like the following syntax:
Which would translate into something like the following:
The text was updated successfully, but these errors were encountered: