MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / test_aware_datetime

Method test_aware_datetime

test/test_bson.py:615–623  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

613 self.assertEqual(dt2.second, dt1.second)
614
615 def test_aware_datetime(self):
616 aware = datetime.datetime(1993, 4, 4, 2, tzinfo=FixedOffset(555, "SomeZone"))
617 offset = aware.utcoffset()
618 assert offset is not None
619 as_utc = (aware - offset).replace(tzinfo=utc)
620 self.assertEqual(datetime.datetime(1993, 4, 3, 16, 45, tzinfo=utc), as_utc)
621 after = decode(encode({"date": aware}), CodecOptions(tz_aware=True))["date"]
622 self.assertEqual(utc, after.tzinfo)
623 self.assertEqual(as_utc, after)
624
625 def test_local_datetime(self):
626 # Timezone -60 minutes of UTC, with DST between April and July.

Callers

nothing calls this directly

Calls 5

FixedOffsetClass · 0.90
decodeFunction · 0.90
encodeFunction · 0.90
CodecOptionsClass · 0.90
utcoffsetMethod · 0.45

Tested by

no test coverage detected