@@ -681,21 +681,18 @@ async def test_context_manager(fake_dapr_client: FakeDaprClient):
681681 # Verify we can still check the state (fake client doesn't truly disconnect)
682682 assert fake_dapr_client ._closed is False # External client not closed
683683
684- # Test with owned client (from_address)
685- mock_address = "localhost:50001"
686- session = DaprSession .from_address (
684+ # Test with owned client scenario (simulating from_address behavior)
685+ owned_session = DaprSession (
687686 "test_cm_owned" ,
688687 state_store_name = "statestore" ,
689- dapr_address = mock_address ,
688+ dapr_client = fake_dapr_client ,
690689 )
690+ # Manually set ownership to simulate from_address behavior
691+ owned_session ._owns_client = True
691692
692- # Replace the internal client with our fake for testing
693- session ._dapr_client = fake_dapr_client
694- session ._owns_client = True
695-
696- async with session :
697- await session .add_items ([{"role" : "user" , "content" : "Owned client test" }])
698- items = await session .get_items ()
693+ async with owned_session :
694+ await owned_session .add_items ([{"role" : "user" , "content" : "Owned client test" }])
695+ items = await owned_session .get_items ()
699696 assert len (items ) == 1
700697
701- # Close should have been called automatically
698+ # Close should have been called automatically (though fake client doesn't track this)
0 commit comments