Skip to content

TST: GH30999 Add match=msg to all but two pytest.raises in tests/io #38724

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 5 commits into from
Dec 28, 2020

Conversation

moink
Copy link
Member

@moink moink commented Dec 27, 2020

This pull request partially addresses xref #30999 to remove bare pytest.raises by adding match=msg. It doesn't close that issue as I have only addressed test modules in the pandas/tests/io/ directory.

I thought this was going to be relatively small because there were only 25 such instances, but it turned out some of them were in methods that were reused several times, so this ended up larger than I expected.

There were a couple of cases where I found the structure of the tests quite confusing, with an internal function definition and two nested asserts. This structure also made it difficult to add the assertion about the error message. I restructured the tests to be, in my opinion, more straightforward.

There's one file, pandas/tests/io/test_sql.py, with two instances of pytest.raises in tests which were skipped on my machine and which I couldn't figure out how to run, so those are left as is.

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

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. one comment. pls merge master and ping on green.

if quoting == csv.QUOTE_NONE:
# We expect no match, so there should be an assertion
# error out of the inner context manager.
with pytest.raises(AssertionError):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, this was some really old testing code

@@ -223,11 +221,12 @@ def test_s3_parquet(s3_resource, s3so):
tm.assert_equal(df1, df2)


@td.skip_if_installed("fsspec")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra skip here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jreback fixed this, merged master, green except for Travis CI

@jreback jreback added Error Reporting Incorrect or improved errors from pandas Testing pandas testing functions or related to the test suite labels Dec 27, 2020
@jreback jreback added this to the 1.3 milestone Dec 27, 2020
@jreback
Copy link
Contributor

jreback commented Dec 27, 2020

There were a couple of cases where I found the structure of the tests quite confusing, with an internal function definition and two nested asserts. This structure also made it difficult to add the assertion about the error message. I restructured the tests to be, in my opinion, more straightforward.

yep your changes are fine. general restructuring of tests should be a dedicated PR, but moderinzation like this is ok.

@jreback jreback merged commit 51941bd into pandas-dev:master Dec 28, 2020
@jreback
Copy link
Contributor

jreback commented Dec 28, 2020

thanks @moink

@moink moink deleted the add_match_msg_to_pytest_raises_io branch December 30, 2020 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants