-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: bare pytest raises in tests/scalar #32929
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 in tests/scalar #32929
Conversation
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.
Thank you so much for taking some of these!
I have some minor comments
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 @quangngd for the PR. generally looks good on first pass. in future can you limit the changes to batches of no more than 5 files.
@@ -225,15 +231,20 @@ def test_constructor_positional(self): | |||
|
|||
def test_constructor_keyword(self): | |||
# GH 10758 | |||
with pytest.raises(TypeError): | |||
msg = "function missing required argument 'day'|Required argument 'day'" |
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.
do you know where these inconsistencies arise?
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.
if we only have function missing required argument 'day'
it would only pass the Linux py36_locale_slow_old_np and Linux py37_locale
azure pipeline
The error was raised by pandas/_libs/tslibs/timestamps.pyx:467
ts_input = datetime(**datetime_kwargs)
Maybe it's a python thing?
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 know all of our pipeline run on py 3 but when looking around, i noticed that when run
open()
Python 3 (3.7.3) would returns TypeError: open() missing required argument 'file' (pos 1)
and
Python 2 (2.7.17) would returns TypeError: Required argument 'name' (pos 1) not found
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, this is an indication that the message is not raised by pandas. what's the policy here @MomIsBestFriend?
@@ -26,14 +26,14 @@ def test_tz_localize_pushes_out_of_bounds(self): | |||
pac = Timestamp.min.tz_localize("US/Pacific") | |||
assert pac.value > Timestamp.min.value | |||
pac.tz_convert("Asia/Tokyo") # tz_convert doesn't change value | |||
with pytest.raises(OutOfBoundsDatetime): | |||
with pytest.raises(OutOfBoundsDatetime, match="^$"): |
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.
would it make sense to have a message 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.
the current implementation returns nothing, it's indeed should better have some message but that's out of the issue's scope
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.
yep, out of scope. but if you could raise an issue, that'll be great.
Timestamp("2015-10-25 02:00", tz=tz) | ||
|
||
result = Timestamp("2017-03-26 01:00", tz="Europe/Paris") | ||
expected = Timestamp("2017-03-26 01:00").tz_localize("Europe/Paris") | ||
assert result == expected | ||
|
||
with pytest.raises(pytz.NonExistentTimeError): | ||
msg = "2017-03-26 02:00" | ||
with pytest.raises(pytz.NonExistentTimeError, 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.
ok to inline short, single use messages
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 @quangngd lgtm. @MomIsBestFriend ok to merge?
Thanks @quangngd |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
#30999