I am having a function with the a default value of a param as datetime.now()
. method is something like below,
def as_standard_format(p_date=datetime.now(), fmt=sdk_constants.DEFAULT_DATE_TIME_FORMAT):
return p_date.strftime(fmt)
And I am having a test method something like below,
@freeze_time(datetime(year=2018, month=9, day=25, hour=15, minute=46, second=36))
def testNowWithDefaultFormat(self):
# The below method gives the frozen time
print(datetime.now())
# But the below test fails
assert utils.format_date(
datetime.now()) == "20180925T154636Z", "Default call not giving current time in " \
"standard format \"%Y%m%dT%H%M%SZ\""
Why is the freeze_time
not working with default param value?