@@ -138,15 +138,23 @@ def run_operation(self, sessions, collection, operation):
138138
139139 # Convert arguments to snake_case and handle special cases.
140140 arguments = operation ['arguments' ]
141- options = arguments .pop ("options" , {})
142- for option_name in options :
143- arguments [camel_to_snake (option_name )] = options [option_name ]
144-
145141 pref = arguments .pop ('readPreference' , None )
146142 if pref :
147143 mode = read_pref_mode_from_name (pref ['mode' ])
148144 collection = collection .with_options (
149145 read_preference = make_read_preference (mode , None ))
146+ write_c = arguments .pop ('writeConcern' , None )
147+ if write_c :
148+ collection = collection .with_options (
149+ write_concern = WriteConcern (** write_c ))
150+ read_c = arguments .pop ('readConcern' , None )
151+ if read_c :
152+ collection = collection .with_options (
153+ read_concern = ReadConcern (** read_c ))
154+
155+ options = arguments .pop ("options" , {})
156+ for option_name in options :
157+ arguments [camel_to_snake (option_name )] = options [option_name ]
150158
151159 if name .endswith ('_transaction' ):
152160 cmd = getattr (session , name )
@@ -181,9 +189,9 @@ def run_operation(self, sessions, collection, operation):
181189 # Requires boolean returnDocument.
182190 elif arg_name == "returnDocument" :
183191 arguments [c2s ] = arguments [arg_name ] == "After"
184- elif arg_name == "readConcern " :
192+ elif c2s == "read_concern " :
185193 arguments [c2s ] = ReadConcern (** arguments .pop (arg_name ))
186- elif arg_name == "writeConcern " :
194+ elif c2s == "write_concern " :
187195 arguments [c2s ] = WriteConcern (** arguments .pop (arg_name ))
188196 else :
189197 arguments [c2s ] = arguments .pop (arg_name )
0 commit comments