-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
TST: Replaced try-catch blocks with pytest.raises #31165
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
TST: Replaced try-catch blocks with pytest.raises #31165
Conversation
tm.assert_series_equal(a, b, **kwargs) | ||
msg = "The two Series were equal when they shouldn't have been" | ||
|
||
pytest.fail(msg=msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think removing this is entirely equivalent; might be root of CI failures
pandas/tests/io/test_sql.py
Outdated
self.conn.close() | ||
except Error: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is kind of a "teardown" method of the tests, so not sure this should use an assert instead of try/except
pandas/tests/io/test_sql.py
Outdated
@@ -538,13 +536,12 @@ class DummyException(Exception): | |||
|
|||
# Make sure when transaction is rolled back, no rows get inserted | |||
ins_sql = "INSERT INTO test_trans (A,B) VALUES (1, 'blah')" | |||
try: | |||
|
|||
with pytest.raises(DummyException): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to assert the exception here, from reading the comment we are just raising it to ensure the transaction is correctly rolled back. I think using a try/except with ignoring the exception makes that clearer.
Thanks @MomIsBestFriend ! |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff