Skip to content

Commit b59a44b

Browse files
authored
Merge pull request #468 from bashtage/check-start-end-date
BUG: Verify start <= end
2 parents 1953452 + 6dda017 commit b59a44b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pandas_datareader/_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ def _sanitize_dates(start, end):
3434
start = dt.datetime(2010, 1, 1)
3535
if end is None:
3636
end = dt.datetime.today()
37+
if start > end:
38+
raise ValueError('start must be an earlier date than end')
3739
return start, end
3840

3941

pandas_datareader/tests/test_bankofcanada.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def get_symbol(currency_code, inverted=False):
1616
return 'FX{}CAD'.format(currency_code)
1717

1818
def check_bankofcanada_count(self, code):
19-
df = web.DataReader(self.get_symbol(code), 'bankofcanada',
20-
date.today() - timedelta(days=30), date.today())
19+
start, end = date.today() - timedelta(days=30), date.today()
20+
df = web.DataReader(self.get_symbol(code), 'bankofcanada', start, end)
2121
assert df.size > 15
2222

2323
def check_bankofcanada_valid(self, code):
@@ -57,7 +57,7 @@ def test_bankofcanada_eur_inverted(self):
5757
self.check_bankofcanada_inverted('EUR')
5858

5959
def test_bankofcanada_bad_range(self):
60-
with pytest.raises(RemoteDataError):
60+
with pytest.raises(ValueError):
6161
web.DataReader('FXCADUSD', 'bankofcanada',
6262
date.today(), date.today() - timedelta(days=30))
6363

0 commit comments

Comments
 (0)