Skip to content

Commit a9e6432

Browse files
committed
PYTHON-1508 Jython-compatible transaction tests
1 parent 84d0338 commit a9e6432

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

test/test_transactions.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ def run_operation(self, sessions, collection, operation):
143143
arguments.pop('readPreference')['mode']), tag_sets=None)
144144

145145
if 'writeConcern' in arguments:
146-
write_c = WriteConcern(**arguments.pop('writeConcern'))
146+
write_c = WriteConcern(**dict(arguments.pop('writeConcern')))
147147

148148
if 'readConcern' in arguments:
149-
read_c = ReadConcern(**arguments.pop('readConcern'))
149+
read_c = ReadConcern(**dict(arguments.pop('readConcern')))
150150

151151
if name == 'start_transaction':
152152
cmd = partial(session.start_transaction,
@@ -187,12 +187,12 @@ def run_operation(self, sessions, collection, operation):
187187
bulk_model = camel_to_upper_camel(request["name"])
188188
bulk_class = getattr(operations, bulk_model)
189189
bulk_arguments = camel_to_snake_args(request["arguments"])
190-
requests.append(bulk_class(**bulk_arguments))
190+
requests.append(bulk_class(**dict(bulk_arguments)))
191191
arguments["requests"] = requests
192192
else:
193193
arguments[c2s] = arguments.pop(arg_name)
194194

195-
result = cmd(**arguments)
195+
result = cmd(**dict(arguments))
196196

197197
if name == "aggregate":
198198
if arguments["pipeline"] and "$out" in arguments["pipeline"][-1]:
@@ -281,8 +281,11 @@ def end_sessions(sessions):
281281
def create_test(scenario_def, test):
282282
def run_scenario(self):
283283
listener = EventListener()
284-
# New client to avoid interference from pooled sessions.
285-
client = rs_client(event_listeners=[listener], **test['clientOptions'])
284+
# New client, to avoid interference from pooled sessions.
285+
# Convert test['clientOptions'] to dict to avoid a Jython bug using "**"
286+
# with ScenarioDict.
287+
client = rs_client(event_listeners=[listener],
288+
**dict(test['clientOptions']))
286289
try:
287290
client.admin.command('killAllSessions', [])
288291
except OperationFailure:
@@ -307,11 +310,13 @@ def run_scenario(self):
307310
if 'default_transaction_options' in opts:
308311
txn_opts = opts['default_transaction_options']
309312
if 'readConcern' in txn_opts:
310-
read_concern = ReadConcern(**txn_opts['readConcern'])
313+
read_concern = ReadConcern(
314+
**dict(txn_opts['readConcern']))
311315
else:
312316
read_concern = None
313317
if 'writeConcern' in txn_opts:
314-
write_concern = WriteConcern(**txn_opts['writeConcern'])
318+
write_concern = WriteConcern(
319+
**dict(txn_opts['writeConcern']))
315320
else:
316321
write_concern = None
317322

@@ -321,7 +326,7 @@ def run_scenario(self):
321326
)
322327
opts['default_transaction_options'] = txn_opts
323328

324-
s = client.start_session(**opts)
329+
s = client.start_session(**dict(opts))
325330

326331
sessions[session_name] = s
327332
# Store lsid so we can access it after end_session, in check_events.

0 commit comments

Comments
 (0)