mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-08 21:49:06 +08:00
ENH: Provides a more descriptive error if market_open or market_close are provided a non-keyword argument that is not a datetime.timedelta
This commit is contained in:
@@ -74,6 +74,11 @@ class TestUtils(TestCase):
|
||||
with self.assertRaises(ValueError):
|
||||
_build_offset(datetime.timedelta(minutes=1), {'minutes': 1}, None)
|
||||
|
||||
def test_build_offset_exc(self):
|
||||
with self.assertRaises(TypeError):
|
||||
# object() is not an instance of a timedelta.
|
||||
_build_offset(object(), {}, None)
|
||||
|
||||
def test_build_offset_kwargs(self):
|
||||
kwargs = {'minutes': 1}
|
||||
self.assertEqual(
|
||||
|
||||
@@ -77,8 +77,10 @@ def _build_offset(offset, kwargs, default):
|
||||
return datetime.timedelta(**kwargs)
|
||||
elif kwargs:
|
||||
raise ValueError('Cannot pass kwargs and an offset')
|
||||
else:
|
||||
elif isinstance(offset, datetime.timedelta):
|
||||
return offset
|
||||
else:
|
||||
raise TypeError("Must pass 'hours' and/or 'minutes' as keywords")
|
||||
|
||||
|
||||
def _build_date(date, kwargs):
|
||||
|
||||
Reference in New Issue
Block a user