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)
评论列表
文章目录