I'm puzzled why a function that freezes time with freezegun outputs different UTC times depending on whether datetime.datetime.utcnow()
is called, or datetime.datetime.now(pytz.utc)
. I'm not saying it's broken, just that I don't understand why, and would like to know!
eg, 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))
the output is:
utcnow(): 2012-01-14 03:21:34
pytz.utc: 2012-01-13 23:21:34+00:00
I guess the first is a naive datetime, but why are they different times?
(Ultimately why I want to know: if I'm using freezegun in my tests, and I use pytz to generate times in my code being tested, I want to know what its 'correct' behaviour should be.)