test_cursor.py 文件源码

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

项目:aiomongo 作者: ZeoAlliance 项目源码 文件源码
def test_count_with_limit_and_skip(self, test_db):
        with pytest.raises(TypeError):
            await test_db.test.find().count('foo')

        async def check_len(cursor, length):
            assert len(await cursor.to_list()) == await cursor.count(True)
            assert length == await cursor.count(True)

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

        await check_len(test_db.test.find(), 100)

        await check_len(test_db.test.find().limit(10), 10)
        await check_len(test_db.test.find().limit(110), 100)

        await check_len(test_db.test.find().skip(10), 90)
        await check_len(test_db.test.find().skip(110), 0)

        await check_len(test_db.test.find().limit(10).skip(10), 10)
        await check_len(test_db.test.find().limit(10).skip(95), 5)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号