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

Use pytest.raises(Exception) in testing exceptions #9

Open
mortele opened this issue Apr 25, 2019 · 0 comments
Open

Use pytest.raises(Exception) in testing exceptions #9

mortele opened this issue Apr 25, 2019 · 0 comments
Labels
testing Related to unit testing

Comments

@mortele
Copy link
Owner

mortele commented Apr 25, 2019

Replace all instances of

caught = False
try:
    some_function(a, b, c)
except TypeError:
    caught = True
assert caught is True

with the native pytest equivalent

with pytest.raises(TypeError) as error:
    some_function(a, b, c)
@mortele mortele added the testing Related to unit testing label Apr 25, 2019
@mortele mortele changed the title Use pytest raises(Exception) in testing exceptions Use pytest.raises(Exception) in testing exceptions Apr 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Related to unit testing
Projects
None yet
Development

No branches or pull requests

1 participant