考虑这种方法manager.py
def get_start_end_time_for(user, year, month):
today = datetime.today()
if today.day < user.financial_day_of_month:
if month == 1:
month = 12
year -= 1
else:
month -= 1
time_from = date(day=user.financial_day_of_month,
month=month, year=year)
time_to = time_from + relativedelta(months=+1)
return time_from, time_to
考虑以下test.py
def test_get_start_end_time_for(user, year, month):
# mock datetime.datetime.today in manager.py
# do further steps
我看着Python: Trying to mock datetime.date.today() but not working但似乎你只能在测试方法中模拟一些东西
我怎样才能datetime.datetime.today
模拟manager.py
?