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

Test that no exceptions were raised #319

Closed
JosephTLyons opened this issue Mar 18, 2022 · 2 comments
Closed

Test that no exceptions were raised #319

JosephTLyons opened this issue Mar 18, 2022 · 2 comments

Comments

@JosephTLyons
Copy link

JosephTLyons commented Mar 18, 2022

I'm currently using the following, which Is fine, but I was curious if Ward had something that replaces this pattern:

try:
    function()
    assert True
except:
    assert False
@JoshKarpel
Copy link
Contributor

A test passes if it doesn't fail, so just

function()

should be sufficient. If an exception was raised during function(), the test would fail automatically.

@JosephTLyons
Copy link
Author

JosephTLyons commented Mar 18, 2022

Ah yeah, that makes a lot of sense. I guess I'm just not used to seeing an assertion-less test, but since assert just raises an AssertionError in the failing case, and any assertion raised is what causes the test to fail within the testing framework, then just calling the function bare would be the thing to do. Ok, thanks, I'll go ahead and close this one out.

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