(self)
| 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 |
nothing calls this directly
no test coverage detected