-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TST: add error message match for raise in test_datetimelike.py GH30999 #37952
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 error message match for raise in test_datetimelike.py GH30999 #37952
Conversation
f"or array of those. Got '{type(string).__name__}' instead." | ||
), | ||
): | ||
arr.searchsorted(string) |
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.
can this (and line 325) be kept as they originally were?
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.
@MarcoGorelli I see the point to keep it as original here. For line325, is it because extract_array()
may change later and break the test? And in contract, StringArray
(type name) is less likely to change.
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.
It's not too important admittedly, it's just to minimise the amount of logic in tests as any assignment / substitution / branch has the potential to introduce bugs. When we write source code we want to write helper functions and not repeat ourselves and all of that, but for tests repetition is more acceptable - see https://testing.googleblog.com/2014/07/testing-on-toilet-dont-put-logic-in.html
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.
Got it. The article is very helpful. Thanks a lot!
f"value should be a '{arr1d._scalar_type.__name__}', 'NaT', " | ||
f"or array of those. Got '{type(string).__name__}' instead." |
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.
match
takes a regular expression, which is checked using re.search
. So the .
s will match any character - can you use match=re.escape(
instead of match=
?
lgtm. @MarcoGorelli merge when ready. |
Thanks @liaoaoyuan97 ! |
Reference #30999
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff