-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: Add match=msg to all pytest.raises in pandas/tests/io/json #38705
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: Add match=msg to all pytest.raises in pandas/tests/io/json #38705
Conversation
json = StringIO('{"articleId":' + str(bigNum) + "}") | ||
msg = r"Value is too small|Value is too big" | ||
with pytest.raises(ValueError, match=msg): | ||
read_json(json) |
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.
Looks like the line for testing the string '{"0":{"articleId":' + str(bigNum) + "}}"
is lost with these changes. The two cases '{"articleId":' + str(bigNum) + "}"
and '{"0":{"articleId":' + str(bigNum) + "}}"
are different, so I think both should be kept.
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.
thanks. looks like I misread it to do the same thing twice.
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.
fixed
…json_large_numbers
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.
Looks good to me, thanks!
pandas/tests/io/json/test_ujson.py
Outdated
"Cannot decode multidimensional arrays with variable length elements to " | ||
"numpy|" | ||
"argument must be a string, a bytes-like object or a number, not|" | ||
"nesting not supported for object or variable length dtypes|" | ||
r"invalid literal for int\(\) with base 10|" | ||
"labels only supported up to 2 dimensions|" | ||
"cannot reshape array of size" |
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 add such a complex match, I would just do a "match all" here
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.
Ok, again I didn't want to do a match all, so I added the error message to the test parameters. It added a lot of lines due to the line length limit, but I think it's ok. Let me know what you think.
I wanted to try this, but if you really don't like it I will do it your way.
thanks @moink the error messages really do help in reading the test code. |
This pull request partially addresses xref #30999 to remove bare
pytest.raises
by addingmatch=msg
. It doesn't close that issue as I have only addressed test modules in tje pandas/tests/io/json directory.I also moved a couple of lines out of the
pytest.raises
context to make clear which pandas method was raising the error. And I deleted a couple of unreachable asserts in tests.black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff