TST: Use pandas relativedelta for calendar end to account for leap year.

Some unit tests for test_tradingcalendar failed on 2015-03-01, because the
addition of 365 days put the end date at 2016-02-29; when the replaces
the year on that date it fails because there is no 2017-02-29.

Instead use relativedelta with a year argument which accounts for leap
years.

Fixes the following test failure:

```
======================================================================
ERROR: test_day_after_thanksgiving (tests.test_tradingcalendar.TestTradingCalendar)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/test_tradingcalendar.py", line 211, in test_day_after_thanksgiving
    tradingcalendar.end.replace(year=tradingcalendar.end.year + 1)
  File "tslib.pyx", line 297, in pandas.tslib.Timestamp.replace (pandas/tslib.c:7325)
ValueError: day is out of range for month

----------------------------------------------------------------------
Ran 1 test in 0.001s
```
This commit is contained in:
Eddie Hebert
2015-03-02 11:02:13 -05:00
parent 98ee8efe3d
commit a64a1ee619
+1 -1
View File
@@ -23,7 +23,7 @@ start = pd.Timestamp('1990-01-01', tz='UTC')
end_base = pd.Timestamp('today', tz='UTC')
# Give an aggressive buffer for logic that needs to use the next trading
# day or minute.
end = end_base + timedelta(days=365)
end = end_base + pd.datetools.relativedelta(years=1)
def canonicalize_datetime(dt):