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

Method test_tz_aware

test/test_client.py:1384–1400  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1382
1383 @no_type_check
1384 def test_tz_aware(self):
1385 self.assertRaises(ValueError, MongoClient, tz_aware="foo")
1386
1387 aware = self.rs_or_single_client(tz_aware=True)
1388 self.addCleanup(aware.close)
1389 naive = self.client
1390 aware.pymongo_test.drop_collection("test")
1391
1392 now = datetime.datetime.now(tz=datetime.timezone.utc)
1393 aware.pymongo_test.test.insert_one({"x": now})
1394
1395 self.assertEqual(None, (naive.pymongo_test.test.find_one())["x"].tzinfo)
1396 self.assertEqual(utc, (aware.pymongo_test.test.find_one())["x"].tzinfo)
1397 self.assertEqual(
1398 (aware.pymongo_test.test.find_one())["x"].replace(tzinfo=None),
1399 (naive.pymongo_test.test.find_one())["x"],
1400 )
1401
1402 @client_context.require_ipv6
1403 def test_ipv6(self):

Callers

nothing calls this directly

Calls 5

rs_or_single_clientMethod · 0.80
addCleanupMethod · 0.80
drop_collectionMethod · 0.45
insert_oneMethod · 0.45
find_oneMethod · 0.45

Tested by

no test coverage detected