Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_date_and_delta():
now = dt.datetime.now()
td = dt.timedelta
int_tests = (3, 29, 86399, 86400, 86401 * 30)
date_tests = [now - td(seconds=x) for x in int_tests]
td_tests = [td(seconds=x) for x in int_tests]
results = [(now - td(seconds=x), td(seconds=x)) for x in int_tests]
for t in (int_tests, date_tests, td_tests):
for arg, result in zip(t, results):
date, d = time.date_and_delta(arg)
assertEqualDatetime(date, result[0])
assertEqualTimedelta(d, result[1])
assert time.date_and_delta("NaN") == (None, "NaN")
def test_date_and_delta():
now = dt.datetime.now()
td = dt.timedelta
int_tests = (3, 29, 86399, 86400, 86401 * 30)
date_tests = [now - td(seconds=x) for x in int_tests]
td_tests = [td(seconds=x) for x in int_tests]
results = [(now - td(seconds=x), td(seconds=x)) for x in int_tests]
for t in (int_tests, date_tests, td_tests):
for arg, result in zip(t, results):
date, d = time.date_and_delta(arg)
assertEqualDatetime(date, result[0])
assertEqualTimedelta(d, result[1])
assert time.date_and_delta("NaN") == (None, "NaN")