Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
super(ArrowSpanTests, self).setUp()
self.datetime = datetime(2013, 2, 15, 3, 41, 22, 8923)
self.arrow = arrow.Arrow.fromdatetime(self.datetime)
def test_exclusive_inclusive_bounds(self):
target = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
start = arrow.Arrow.fromdatetime(datetime(2013, 5, 5))
end = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
result = target.is_between(start, end, "(]")
self.assertTrue(result)
def test_inclusive_inclusive_bounds_same_date(self):
target = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
start = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
end = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
result = target.is_between(start, end, "[]")
self.assertTrue(result)
def test_type_error_exception(self):
with self.assertRaises(TypeError):
target = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
start = datetime(2013, 5, 5)
end = arrow.Arrow.fromdatetime(datetime(2013, 5, 8))
target.is_between(start, end)
with self.assertRaises(TypeError):
target = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
start = arrow.Arrow.fromdatetime(datetime(2013, 5, 5))
end = datetime(2013, 5, 8)
target.is_between(start, end)
with self.assertRaises(TypeError):
target.is_between(None, None)
def test_exclusive_exclusive_bounds_same_date(self):
target = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
start = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
end = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
result = target.is_between(start, end, "()")
self.assertFalse(result)
def test_to(self):
dt_from = datetime.now()
arrow_from = arrow.Arrow.fromdatetime(dt_from, tz.gettz("US/Pacific"))
self.expected = dt_from.replace(tzinfo=tz.gettz("US/Pacific")).astimezone(
tz.tzutc()
)
self.assertEqual(arrow_from.to("UTC").datetime, self.expected)
self.assertEqual(arrow_from.to(tz.tzutc()).datetime, self.expected)
def test_exclusive_inclusive_bounds(self):
target = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
start = arrow.Arrow.fromdatetime(datetime(2013, 5, 5))
end = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
result = target.is_between(start, end, "(]")
self.assertTrue(result)
if end is None:
if limit is None:
raise ValueError("one of 'end' or 'limit' is required")
return cls.max, limit
else:
if limit is None:
return end, sys.maxsize
return end, limit
Arrow.min = Arrow.fromdatetime(datetime.min)
Arrow.max = Arrow.fromdatetime(datetime.max)
def _get_iteration_params(cls, end, limit):
if end is None:
if limit is None:
raise ValueError("one of 'end' or 'limit' is required")
return cls.max, limit
else:
if limit is None:
return end, sys.maxsize
return end, limit
Arrow.min = Arrow.fromdatetime(datetime.min)
Arrow.max = Arrow.fromdatetime(datetime.max)