@@ -109,7 +109,6 @@ class TestCollection(IntegrationTest):
109109 @classmethod
110110 def setUpClass (cls ):
111111 super (TestCollection , cls ).setUpClass ()
112- cls .db = client_context .client .pymongo_test
113112 cls .w = client_context .w
114113
115114 @classmethod
@@ -410,7 +409,7 @@ def test_index_haystack(self):
410409 @client_context .require_version_min (2 , 3 , 2 )
411410 @client_context .require_no_mongos
412411 def test_index_text (self ):
413- enable_text_search (client_context .client )
412+ enable_text_search (self .client )
414413
415414 db = self .db
416415 db .test .drop_indexes ()
@@ -955,7 +954,7 @@ def test_save_with_invalid_key(self):
955954 def test_unique_index (self ):
956955 db = self .db
957956
958- with client_context .client .start_request ():
957+ with self .client .start_request ():
959958 db .drop_collection ("test" )
960959 db .test .create_index ("hello" )
961960
@@ -1041,7 +1040,7 @@ def test_continue_on_error(self):
10411040 docs .append ({"four" : 4 })
10421041 docs .append ({"five" : 5 })
10431042
1044- with client_context .client .start_request ():
1043+ with self .client .start_request ():
10451044 db .test .insert (docs , manipulate = False , w = 0 )
10461045 self .assertEqual (11000 , db .error ()['code' ])
10471046 self .assertEqual (1 , db .test .count ())
@@ -1093,7 +1092,7 @@ def test_index_on_subfield(self):
10931092 db .test .insert , {"hello" : {"a" : 4 , "b" : 10 }})
10941093
10951094 def test_safe_insert (self ):
1096- with client_context .client .start_request ():
1095+ with self .client .start_request ():
10971096 db = self .db
10981097 db .drop_collection ("test" )
10991098
@@ -1145,7 +1144,7 @@ def transform_incoming(self, son, collection):
11451144 def test_update_nmodified (self ):
11461145 db = self .db
11471146 db .drop_collection ("test" )
1148- used_write_commands = (client_context .client .max_wire_version > 1 )
1147+ used_write_commands = (self .client .max_wire_version > 1 )
11491148
11501149 db .test .insert ({'_id' : 1 })
11511150 result = db .test .update ({'_id' : 1 }, {'$set' : {'x' : 1 }})
@@ -1190,7 +1189,7 @@ def test_upsert(self):
11901189 self .assertEqual (2 , db .test .find_one ()["count" ])
11911190
11921191 def test_safe_update (self ):
1193- with client_context .client .start_request ():
1192+ with self .client .start_request ():
11941193 db = self .db
11951194 v113minus = client_context .version .at_least (1 , 1 , 3 , - 1 )
11961195 v19 = client_context .version .at_least (1 , 9 )
@@ -1264,7 +1263,7 @@ def test_update_with_invalid_keys(self):
12641263 {})['n' ])
12651264
12661265 def test_safe_save (self ):
1267- with client_context .client .start_request ():
1266+ with self .client .start_request ():
12681267 db = self .db
12691268 db .drop_collection ("test" )
12701269 db .test .create_index ("hello" , unique = True )
@@ -1844,7 +1843,7 @@ def test_insert_large_document(self):
18441843 self .db .test .update ({"bar" : "x" }, {"bar" : "x" * (max_size - 32 )})
18451844
18461845 def test_insert_large_batch (self ):
1847- max_bson_size = client_context .client .max_bson_size
1846+ max_bson_size = self .client .max_bson_size
18481847 if client_context .version .at_least (2 , 5 , 4 , - 1 ):
18491848 # Write commands are limited to 16MB + 16k per batch
18501849 big_string = 'x' * int (max_bson_size / 2 )
@@ -1868,7 +1867,7 @@ def test_insert_large_batch(self):
18681867
18691868 # Test that inserts fail after first error, unacknowledged.
18701869 self .db .test .drop ()
1871- with client_context .client .start_request ():
1870+ with self .client .start_request ():
18721871 self .assertTrue (self .db .test .insert (batch , w = 0 ))
18731872 self .assertEqual (1 , self .db .test .count ())
18741873
@@ -1887,7 +1886,7 @@ def test_insert_large_batch(self):
18871886
18881887 # 2 batches, 2 errors, unacknowledged, continue on error
18891888 self .db .test .drop ()
1890- with client_context .client .start_request ():
1889+ with self .client .start_request ():
18911890 self .assertTrue (
18921891 self .db .test .insert (batch , continue_on_error = True , w = 0 ))
18931892 # Only the first and third documents should be inserted.
@@ -2002,7 +2001,7 @@ def test_map_reduce(self):
20022001 self .assertEqual (3 , result .find_one ({"_id" : "cat" })["value" ])
20032002 self .assertEqual (2 , result .find_one ({"_id" : "dog" })["value" ])
20042003 self .assertEqual (1 , result .find_one ({"_id" : "mouse" })["value" ])
2005- client_context .client .drop_database ('mrtestdb' )
2004+ self .client .drop_database ('mrtestdb' )
20062005
20072006 full_result = db .test .map_reduce (map , reduce ,
20082007 out = 'mrunittests' , full_response = True )
@@ -2306,7 +2305,7 @@ def transform_outgoing(self, son, collection):
23062305 son ['foo' ] += 2
23072306 return son
23082307
2309- db = client_context .client .pymongo_test
2308+ db = self .client .pymongo_test
23102309 db .add_son_manipulator (IncByTwo ())
23112310 c = db .test
23122311 c .drop ()
0 commit comments