@@ -1036,20 +1036,28 @@ def test_database_aggregation(self):
1036
1036
@client_context .require_version_min (3 , 6 , 0 )
1037
1037
@client_context .require_no_mongos
1038
1038
def test_database_aggregation_fake_cursor (self ):
1039
- admin = self .admin .with_options (write_concern = WriteConcern (w = 0 ))
1040
- test_collection_name = "test_output"
1041
- admin .drop_collection (test_collection_name )
1042
- self .addCleanup (admin .drop_collection , test_collection_name )
1039
+ coll_name = "test_output"
1040
+ if client_context .version < (4 , 3 ):
1041
+ db_name = "admin"
1042
+ write_stage = {"$out" : coll_name }
1043
+ else :
1044
+ # SERVER-43287 disallows writing with $out to the admin db, use
1045
+ # $merge instead.
1046
+ db_name = "pymongo_test"
1047
+ write_stage = {
1048
+ "$merge" : {"into" : {"db" : db_name , "coll" : coll_name }}}
1049
+ output_coll = self .client [db_name ][coll_name ]
1050
+ output_coll .drop ()
1051
+ self .addCleanup (output_coll .drop )
1043
1052
1053
+ admin = self .admin .with_options (write_concern = WriteConcern (w = 0 ))
1044
1054
pipeline = self .pipeline [:]
1045
- pipeline .append ({ "$out" : "test_output" } )
1055
+ pipeline .append (write_stage )
1046
1056
with admin .aggregate (pipeline ) as cursor :
1047
1057
with self .assertRaises (StopIteration ):
1048
1058
next (cursor )
1049
1059
1050
- result = wait_until (
1051
- admin [test_collection_name ].find_one ,
1052
- "read unacknowledged write" )
1060
+ result = wait_until (output_coll .find_one , "read unacknowledged write" )
1053
1061
self .assertEqual (result ["dummy" ], self .result ["dummy" ])
1054
1062
1055
1063
@client_context .require_version_max (3 , 6 , 0 , - 1 )
0 commit comments