Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (29 sloc) 1.22 KB
import datetime
from freezegun import freeze_time
from dateutil.relativedelta import relativedelta
def test_addition():
now = datetime.datetime.now()
later = now + datetime.timedelta(days=1)
other_later = now + relativedelta(days=1)
assert isinstance(later, datetime.datetime)
assert isinstance(other_later, datetime.datetime)
today = datetime.date.today()
tomorrow = today + datetime.timedelta(days=1)
other_tomorrow = today + relativedelta(days=1)
assert isinstance(tomorrow, datetime.date)
assert isinstance(other_tomorrow, datetime.date)
def test_subtraction():
now = datetime.datetime.now()
before = now - datetime.timedelta(days=1)
other_before = now - relativedelta(days=1)
how_long = now - before
assert isinstance(before, datetime.datetime)
assert isinstance(other_before, datetime.datetime)
assert isinstance(how_long, datetime.timedelta)
today = datetime.date.today()
yesterday = today - datetime.timedelta(days=1)
other_yesterday = today - relativedelta(days=1)
how_long = today - yesterday
assert isinstance(yesterday, datetime.date)
assert isinstance(other_yesterday, datetime.date)
assert isinstance(how_long, datetime.timedelta)
Jump to Line
Something went wrong with that request. Please try again.