@@ -586,5 +586,29 @@ async def callback(session):
586586 self .assertFalse (s .in_transaction )
587587
588588
589+ class TestOptionsInsideTransactionProse (AsyncTransactionsBase ):
590+ @async_client_context .require_transactions
591+ @async_client_context .require_no_standalone
592+ async def test_case_1 (self ):
593+ # Write concern not inherited from collection object inside transaction
594+ # Create a MongoClient running against a configured sharded/replica set/load balanced cluster.
595+ client = async_client_context .client
596+ coll = client [self .db .name ].test
597+ await coll .delete_many ({})
598+ # Start a new session on the client.
599+ async with client .start_session () as s :
600+ # Start a transaction on the session.
601+ await s .start_transaction ()
602+ # Instantiate a collection object in the driver with a default write concern of { w: 0 }.
603+ inner_coll = coll .with_options (write_concern = WriteConcern (w = 0 ))
604+ # Insert the document { n: 1 } on the instantiated collection.
605+ result = await inner_coll .insert_one ({"n" : 1 }, session = s )
606+ # Commit the transaction.
607+ await s .commit_transaction ()
608+ # End the session.
609+ # Ensure the document was inserted and no error was thrown from the transaction.
610+ assert result .inserted_id is not None
611+
612+
589613if __name__ == "__main__" :
590614 unittest .main ()
0 commit comments