Skip to content

Prevent passing invalid kwds to DateOffset constructors #18226

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

Merged
merged 35 commits into from
Nov 25, 2017
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b9fe60e
Patch __init__ to prevent passing invalid kwds
jbrockmendel Nov 11, 2017
f10a1c6
cast n to integer, assert equality
jbrockmendel Nov 11, 2017
807d769
whatsnew note
jbrockmendel Nov 11, 2017
687e3b7
parameterize tests, define fixture where it is used
jbrockmendel Nov 11, 2017
d5443ca
fixup
jbrockmendel Nov 11, 2017
5e5e0c0
exclude base classes from testing
jbrockmendel Nov 11, 2017
17f7b5a
exclude base classes from testing
jbrockmendel Nov 11, 2017
3834ef8
dummy commit to force CI
jbrockmendel Nov 12, 2017
1c54e96
edits per reviewer suggestions
jbrockmendel Nov 12, 2017
0e37a24
whatsnew whitespace
jbrockmendel Nov 12, 2017
a572368
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
jbrockmendel Nov 13, 2017
d0ff381
whitespace fixup
jbrockmendel Nov 13, 2017
409dbd0
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
jbrockmendel Nov 14, 2017
6a9233e
break up hour test to debug appveyor error (segfault?)
jbrockmendel Nov 15, 2017
4406df8
break down segfaulting test to debug
jbrockmendel Nov 16, 2017
44891cd
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
jbrockmendel Nov 16, 2017
573abb6
fixturize
jbrockmendel Nov 16, 2017
c6cc8bc
troubleshoot segfault by moving __eq__ to _BaseOffset
jbrockmendel Nov 17, 2017
a68f4a7
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
jbrockmendel Nov 17, 2017
c8224c1
try sorting rd_kwds to fix segfault, revert other troubleshooting gue…
jbrockmendel Nov 17, 2017
55779d8
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
jbrockmendel Nov 17, 2017
d5b8302
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
jbrockmendel Nov 19, 2017
b54e26b
implement _validate_n method
jbrockmendel Nov 19, 2017
fade4a2
test for _validate_n
jbrockmendel Nov 19, 2017
38c2238
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
jbrockmendel Nov 22, 2017
fe895ff
Raise TypeError, not ValueError
jbrockmendel Nov 22, 2017
11ba1a9
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
jbrockmendel Nov 22, 2017
bc90a19
Catch ValueError in int(n)
jbrockmendel Nov 22, 2017
0b3dca0
fixup extra imports
jbrockmendel Nov 22, 2017
9c841fc
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
jbrockmendel Nov 22, 2017
adee395
remove unnecessary re-definitions, add tests, improve error msg
jbrockmendel Nov 23, 2017
43dc17e
Add docstring to validate_n
jbrockmendel Nov 23, 2017
4ff8c22
fixup missing format
jbrockmendel Nov 24, 2017
d261be9
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
jbrockmendel Nov 24, 2017
b4b9e15
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
jbrockmendel Nov 25, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
break up hour test to debug appveyor error (segfault?)
  • Loading branch information
jbrockmendel committed Nov 15, 2017
commit 6a9233ecebd0741400d6d61fda4fb91dd77112eb
48 changes: 34 additions & 14 deletions pandas/tests/tseries/offsets/test_ticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,40 @@ def test_delta_to_tick():
# ---------------------------------------------------------------------


def test_Hour():
assert_offset_equal(Hour(),
datetime(2010, 1, 1), datetime(2010, 1, 1, 1))
assert_offset_equal(Hour(-1),
datetime(2010, 1, 1, 1), datetime(2010, 1, 1))
assert_offset_equal(2 * Hour(),
datetime(2010, 1, 1), datetime(2010, 1, 1, 2))
assert_offset_equal(-1 * Hour(),
datetime(2010, 1, 1, 1), datetime(2010, 1, 1))

assert Hour(3) + Hour(2) == Hour(5)
assert Hour(3) - Hour(2) == Hour()

assert Hour(4) != Hour(1)
class TestHour(object):
def test_hour_add_hour(self):
assert Hour(3) + Hour(2) == Hour(5)

def test_hour_sub_hour(self):
assert Hour(3) - Hour(2) == Hour()

def test_hour_neq_hours(self):
assert Hour(4) != Hour(1)

def test_neg_hour(self):
assert_offset_equal(-1 * Hour(),
datetime(2010, 1, 1, 1), datetime(2010, 1, 1))

def test_negative_n(self):
assert_offset_equal(Hour(-1),
datetime(2010, 1, 1, 1),
datetime(2010, 1, 1))

def test_one_hour(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if you need to move __eq__ to _BaseOffset

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For lack of any better ideas, let's give it a shot.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If somehow this does fix the error, pls don't merge it just yet. I'm trying to avoid moving methods to the cython classes until I've vetted them, and __eq__ is very much not OK.

v1 = Hour()
v2 = Hour(n=1)
assert v1 == v2
assert v1 + datetime(2010, 1, 1) == v2 + datetime(2010, 1, 1)
assert_offset_equal(Hour(),
datetime(2010, 1, 1), datetime(2010, 1, 1, 1))

def test_multiple_hours(self):
v1 = Hour(n=2)
v2 = 2 * Hour()
assert v1 == v2
assert v1 + datetime(2010, 1, 1) == v2 + datetime(2010, 1, 1)
assert_offset_equal(2 * Hour(),
datetime(2010, 1, 1), datetime(2010, 1, 1, 2))


def test_Minute():
Expand Down