MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / test_rewind

Method test_rewind

test/test_cursor.py:864–894  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

862 self.assertRaises(InvalidOperation, a.where, "this.x < 3")
863
864 def test_rewind(self):
865 self.db.test.insert_many([{"x": i} for i in range(1, 4)])
866
867 cursor = self.db.test.find().limit(2)
868
869 count = 0
870 for _ in cursor:
871 count += 1
872 self.assertEqual(2, count)
873
874 count = 0
875 for _ in cursor:
876 count += 1
877 self.assertEqual(0, count)
878
879 cursor.rewind()
880 count = 0
881 for _ in cursor:
882 count += 1
883 self.assertEqual(2, count)
884
885 cursor.rewind()
886 count = 0
887 for _ in cursor:
888 break
889 cursor.rewind()
890 for _ in cursor:
891 count += 1
892 self.assertEqual(2, count)
893
894 self.assertEqual(cursor, cursor.rewind())
895
896 # oplog_reply, and snapshot are all deprecated.
897 @ignore_deprecations

Callers

nothing calls this directly

Calls 4

insert_manyMethod · 0.45
limitMethod · 0.45
findMethod · 0.45
rewindMethod · 0.45

Tested by

no test coverage detected