Skip to content
Merged
Changes from 1 commit
Commits
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
8 changes: 8 additions & 0 deletions pandas/tests/series/test_datetime_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,11 @@ def test_date_tz(self):
date(2015, 11, 22)])
assert_series_equal(s.dt.date, expected)
assert_series_equal(s.apply(lambda x: x.date()), expected)

def test_datetime_understood(self):
# Ensures it doesn't throw an exception reported in #16726
try:
pd.Series(pd.date_range("2012-01-01", periods=3)) - pd.offsets.DateOffset(days=6)
except Exception:
assert 'data type "datetime" not understood'
Copy link
Contributor

Choose a reason for hiding this comment

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

This test will always pass, since

  • if there's no exception originally, everything is fine
  • If there is an exception, the assert 'data type "datetime" not understood' is True, so no AssertionError is raised

It's best to assign result = that operation, construct an expected series expected = pd.Series(pd.to_datetime(['2011-12-26', '2011-12-27', '2011-12-28']) and then compare them with tm.assert_series_equal(result, expected)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. My bad!

Please check now.