From d99b95a2c62033a5b7ba73a6716aeae2f56a3fbd Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Mon, 30 Oct 2017 08:34:47 -0700 Subject: [PATCH 1/3] follow-up to #17943, closes #5168 --- pandas/tests/scalar/test_timestamp.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pandas/tests/scalar/test_timestamp.py b/pandas/tests/scalar/test_timestamp.py index 97b58628f1295..f6c767229c7e6 100644 --- a/pandas/tests/scalar/test_timestamp.py +++ b/pandas/tests/scalar/test_timestamp.py @@ -176,13 +176,19 @@ def test_constructor_invalid(self): Timestamp(Period('1000-01-01')) def test_constructor_invalid_tz(self): - # GH#17690, GH#5168 + # GH#17690 with tm.assert_raises_regex(TypeError, 'must be a datetime.tzinfo'): Timestamp('2017-10-22', tzinfo='US/Eastern') with tm.assert_raises_regex(ValueError, 'at most one of'): Timestamp('2017-10-22', tzinfo=utc, tz='UTC') + with tm.assert_raises_regex(ValueError: "Invalid frequency:"): + # GH#5168 + # case where user tries to pass tz as an arg, not kwarg, gets + # interpreted as a `freq` + Timestamp('2012-01-01', 'US/Pacific') + def test_constructor_tz_or_tzinfo(self): # GH#17943, GH#17690, GH#5168 stamps = [Timestamp(year=2017, month=10, day=22, tz='UTC'), From b86cfd247c90876200133a28f625355d4c6f567b Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Mon, 30 Oct 2017 08:36:42 -0700 Subject: [PATCH 2/3] typo fixup --- pandas/tests/scalar/test_timestamp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/scalar/test_timestamp.py b/pandas/tests/scalar/test_timestamp.py index f6c767229c7e6..efee096797510 100644 --- a/pandas/tests/scalar/test_timestamp.py +++ b/pandas/tests/scalar/test_timestamp.py @@ -183,7 +183,7 @@ def test_constructor_invalid_tz(self): with tm.assert_raises_regex(ValueError, 'at most one of'): Timestamp('2017-10-22', tzinfo=utc, tz='UTC') - with tm.assert_raises_regex(ValueError: "Invalid frequency:"): + with tm.assert_raises_regex(ValueError, "Invalid frequency:"): # GH#5168 # case where user tries to pass tz as an arg, not kwarg, gets # interpreted as a `freq` From 0b2315f2567f18a12f8627a7ec57dbffcf852a22 Mon Sep 17 00:00:00 2001 From: Brock Mendel Date: Mon, 30 Oct 2017 17:25:49 -0700 Subject: [PATCH 3/3] whatsnew --- doc/source/whatsnew/v0.22.0.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v0.22.0.txt b/doc/source/whatsnew/v0.22.0.txt index 87ac2c9a18347..5ccbc48316b4f 100644 --- a/doc/source/whatsnew/v0.22.0.txt +++ b/doc/source/whatsnew/v0.22.0.txt @@ -42,9 +42,9 @@ Other API Changes - ``NaT`` division with :class:`datetime.timedelta` will now return ``NaN`` instead of raising (:issue:`17876`) - All-NaN levels in ``MultiIndex`` are now assigned float rather than object dtype, coherently with flat indexes (:issue:`17929`). -- :class:`Timestamp` will no longer silently ignore unused or invalid `tz` or `tzinfo` arguments (:issue:`17690`) +- :class:`Timestamp` will no longer silently ignore unused or invalid `tz` or `tzinfo` keyword arguments (:issue:`17690`) +- :class:`Timestamp` will no longer silently ignore invalid `freq` arguments (:issue:`5168`) - :class:`CacheableOffset` and :class:`WeekDay` are no longer available in the `tseries.offsets` module (:issue:`17830`) -- .. _whatsnew_0220.deprecations: