Skip to content

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

Merged
merged 7 commits into from
Jan 23, 2020

Conversation

ShaharNaveh
Copy link
Member

  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff

tm.assert_series_equal(a, b, **kwargs)
msg = "The two Series were equal when they shouldn't have been"

pytest.fail(msg=msg)
Copy link
Member

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

self.conn.close()
except Error:
pass
Copy link
Member

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

@@ -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):
Copy link
Member

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.

@jorisvandenbossche jorisvandenbossche merged commit 08af93a into pandas-dev:master Jan 23, 2020
@jorisvandenbossche
Copy link
Member

Thanks @MomIsBestFriend !

@ShaharNaveh ShaharNaveh deleted the TST-try-catch branch January 24, 2020 12:19
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

Successfully merging this pull request may close these issues.

3 participants