I am puzzled why a function that delays time using freezegun gives a different UTC time depending on whether datetime.datetime.utcnow()or is datetime.datetime.now(pytz.utc)called. I’m not saying that it’s broken, I just don’t understand why I would like to know!
for example using this function:
@freeze_time("2012-01-14 03:21:34", tz_offset=-4)
def test():
print("utcnow(): %s" % datetime.datetime.utcnow())
print("pytz.utc: %s" % datetime.datetime.now(pytz.utc))
conclusion:
utcnow(): 2012-01-14 03:21:34
pytz.utc: 2012-01-13 23:21:34+00:00
I assume the first is a naive datetime, but why are they different times?
(Ultimately, why I want to know: if I use freezegun in my tests, and I use pytz to generate time in the test code, I want to know what its “correct” behavior is.)
source
share