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

Method test_id_ordering

test/test_database.py:469–487  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

467 )
468
469 def test_id_ordering(self):
470 # PyMongo attempts to have _id show up first
471 # when you iterate key/value pairs in a document.
472 # This isn't reliable since python dicts don't
473 # guarantee any particular order. This will never
474 # work right in any Python or environment
475 # with hash randomization enabled (e.g. tox).
476 db = self.client.pymongo_test
477 db.test.drop()
478 db.test.insert_one(SON([("hello", "world"), ("_id", 5)]))
479
480 db = self.client.get_database(
481 "pymongo_test", codec_options=CodecOptions(document_class=SON[str, Any])
482 )
483 cursor = db.test.find()
484 for x in cursor:
485 for k, _v in x.items():
486 self.assertEqual(k, "_id")
487 break
488
489 def test_deref(self):
490 db = self.client.pymongo_test

Callers

nothing calls this directly

Calls 7

SONClass · 0.90
CodecOptionsClass · 0.90
itemsMethod · 0.80
dropMethod · 0.45
insert_oneMethod · 0.45
get_databaseMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected