-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: Bare pytest raises #38576
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: Bare pytest raises #38576
Conversation
pandas/tests/extension/base/ops.py
Outdated
msg = ( | ||
"(unsupported operand type\\(s\\) for)|" | ||
"(cannot perform [\\w_]+ with this index type: [\\w_]+)|" | ||
"(Object with dtype category cannot perform the numpy op [\\w_]+)|" | ||
"(cannot add [\\w_]+ and [\\w_]+)|" | ||
"(can't multiply sequence by non-int of type '[\\w_]+')|" | ||
'(can only concatenate str \\(not "[\\w_]+"\\) to str)|' | ||
"(Object with dtype category cannot perform the numpy op [\\w_]+)|" | ||
"(Concatenation operation is not implemented for NumPy arrays)" | ||
) | ||
with pytest.raises(exc, match=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.
nice! I haven't tried running this, but I would have thought that the parentheses would be redundant - does
msg = ( | |
"(unsupported operand type\\(s\\) for)|" | |
"(cannot perform [\\w_]+ with this index type: [\\w_]+)|" | |
"(Object with dtype category cannot perform the numpy op [\\w_]+)|" | |
"(cannot add [\\w_]+ and [\\w_]+)|" | |
"(can't multiply sequence by non-int of type '[\\w_]+')|" | |
'(can only concatenate str \\(not "[\\w_]+"\\) to str)|' | |
"(Object with dtype category cannot perform the numpy op [\\w_]+)|" | |
"(Concatenation operation is not implemented for NumPy arrays)" | |
) | |
with pytest.raises(exc, match=msg): | |
msg = ( | |
"unsupported operand type\\(s\\) for|" | |
"cannot perform [\\w_]+ with this index type: [\\w_]+|" | |
"Object with dtype category cannot perform the numpy op [\\w_]+|" | |
"cannot add [\\w_]+ and [\\w_]+|" | |
"can't multiply sequence by non-int of type '[\\w_]+'|" | |
'can only concatenate str \\(not "[\\w_]+"\\) to str|' | |
"Object with dtype category cannot perform the numpy op [\\w_]+|" | |
"Concatenation operation is not implemented for NumPy arrays" | |
) | |
with pytest.raises(exc, match=msg): |
work?
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 tested it; it works without the parentheses, I put them there just to be cautious. I'll push a new commit removing them in a moment :-]
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 @MJafarMashhadi |
This are base extension tests, which are also used by external projects. IMO, we should not be adding such specific message tests. I would propose to revert this change. (and @MJafarMashhadi, to be clear, not your fault!) |
Makes sense Should this be reverted and then |
Yes, please revert that. I need to hardcode specific messages now in xhochy/fletcher#212 |
Will do a revert tomorrow |
This reverts commit 9919623.
@jorisvandenbossche There are 4 files that are changed in this PR, two of them are not in |
The non-extension tests in |
* test_assert_series_equal.py * test_setitem_slice_mismatch_length_raises * test_setitem_scalar_key_sequence_raise * test_sub * test_arithmetic * black pandas on test_arithmetic.py * black pandas on setitem.py * BaseComparisonOpsTests * extension/base/ops.py * Break too long lines * The numpy error was an external one * Update RegExs to match more tests * Added new error messages * Removed redundant parenthesis in regexps
…38748) * Revert "TST: Bare pytest raises (pandas-dev#38576)" This reverts commit 9919623.
xref [Good first issue] TST: Disallow bare pytest.raises #30999
tests added / passed
passes
black pandas
passes
git diff upstream/master -u -- "*.py" | flake8 --diff
whatsnew entry [N/A]