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