can't iterate on a collection
This commit is contained in:
parent
601b1618ad
commit
163680bc16
@ -367,3 +367,9 @@ class Collection(object):
|
||||
del options["create"]
|
||||
|
||||
return options
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def next(self):
|
||||
raise TypeError("'Collection' object is not iterable")
|
||||
|
||||
@ -137,6 +137,14 @@ class TestCollection(unittest.TestCase):
|
||||
self.assertEqual(db.test.find().count(), 1)
|
||||
self.assertEqual(doc, db.test.find_one())
|
||||
|
||||
def test_iteration(self):
|
||||
db = self.db
|
||||
|
||||
def iterate():
|
||||
[a for a in db.test]
|
||||
|
||||
self.assertRaises(TypeError, iterate)
|
||||
|
||||
# TODO enable this test when Mongo insert multiple is fixed
|
||||
# OR remove the insert a list functionality from the driver
|
||||
# def test_insert_multiple(self):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user