test_cursor.py 文件源码

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

项目:aiomongo 作者: ZeoAlliance 项目源码 文件源码
def test_count(self, test_db):

        assert 0 == await test_db.test.find().count()

        await test_db.test.insert_many([{'x': i} for i in range(10)])

        assert 10 == await test_db.test.find().count()
        assert isinstance(await test_db.test.find().count(), int)
        assert 10 == await test_db.test.find().limit(5).count()
        assert 10 == await test_db.test.find().skip(5).count()

        assert 1 == await test_db.test.find({'x': 1}).count()
        assert 5 == await test_db.test.find({'x': {'$lt': 5}}).count()

        a = test_db.test.find()
        b = await a.count()
        async for _ in a:
            break
        assert b == await a.count()

        assert 0 == await test_db.test.acollectionthatdoesntexist.find().count()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号