test_collection.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:aiomongo 作者: ZeoAlliance 项目源码 文件源码
def test_id_can_be_anything(self, test_db):
        await test_db.test.delete_many({})
        auto_id = {'hello': 'world'}
        await test_db.test.insert_one(auto_id)
        assert isinstance(auto_id['_id'], ObjectId)

        numeric = {'_id': 240, 'hello': 'world'}
        await test_db.test.insert_one(numeric)
        assert numeric['_id'] == 240

        obj = {'_id': numeric, 'hello': 'world'}
        await test_db.test.insert_one(obj)
        assert obj['_id'] == numeric

        async with test_db.test.find() as cursor:
            async for x in cursor:
                assert x['hello'] == 'world'
                assert '_id' in x
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号