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

Method test_clone

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

Source from the content-addressed store, hash-verified

896 # oplog_reply, and snapshot are all deprecated.
897 @ignore_deprecations
898 def test_clone(self):
899 self.db.test.insert_many([{"x": i} for i in range(1, 4)])
900
901 cursor = self.db.test.find().limit(2)
902
903 count = 0
904 for _ in cursor:
905 count += 1
906 self.assertEqual(2, count)
907
908 count = 0
909 for _ in cursor:
910 count += 1
911 self.assertEqual(0, count)
912
913 cursor = cursor.clone()
914 cursor2 = cursor.clone()
915 count = 0
916 for _ in cursor:
917 count += 1
918 self.assertEqual(2, count)
919 for _ in cursor2:
920 count += 1
921 self.assertEqual(4, count)
922
923 cursor.rewind()
924 count = 0
925 for _ in cursor:
926 break
927 cursor = cursor.clone()
928 for _ in cursor:
929 count += 1
930 self.assertEqual(2, count)
931
932 self.assertNotEqual(cursor, cursor.clone())
933
934 # Just test attributes
935 cursor = (
936 self.db.test.find(
937 {"x": re.compile("^hello.*")},
938 projection={"_id": False},
939 skip=1,
940 no_cursor_timeout=True,
941 cursor_type=CursorType.TAILABLE_AWAIT,
942 sort=[("x", 1)],
943 allow_partial_results=True,
944 oplog_replay=True,
945 batch_size=123,
946 collation={"locale": "en_US"},
947 hint=[("_id", 1)],
948 max_scan=100,
949 max_time_ms=1000,
950 return_key=True,
951 show_record_id=True,
952 snapshot=True,
953 allow_disk_use=True,
954 )
955 ).limit(2)

Callers

nothing calls this directly

Calls 12

copyMethod · 0.80
keysMethod · 0.80
insert_manyMethod · 0.45
limitMethod · 0.45
findMethod · 0.45
cloneMethod · 0.45
rewindMethod · 0.45
maxMethod · 0.45
minMethod · 0.45
add_optionMethod · 0.45
commentMethod · 0.45
hintMethod · 0.45

Tested by

no test coverage detected