-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add support for with snapshot() #81
Comments
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 |
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 |
this was implemented in 0.12.0 https://15r10nk.github.io/inline-snapshot/extra/#inline_snapshot.extra.raises |
You're a rockstar! Thanks! |
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: