You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
1. Successful Stream Close Within Timeout
Purpose: Ensure
send_message
succeeds and does not raise an error under normal conditions.Test Setup:
send_message
to complete within 1 second.muxed_conn.is_shutting_down()
returnsFalse
.Expected Result:
2. Stream Close Times Out
Purpose: Verify that a
TimeoutError
is raised whensend_message
takes too long.Test Setup:
send_message
to block > 5 seconds (e.g., usingawait trio.sleep(6)
).muxed_conn.is_shutting_down()
returnsFalse
.Expected Result:
trio.TooSlowError
is caught.TimeoutError("Stream close timed out")
is raised.3. Muxed Connection Unavailable (Not Shutting Down)
Purpose: Ensure a
RuntimeError
is raised when the connection is unavailable unexpectedly.Test Setup:
send_message
to raiseMuxedConnUnavailable
.muxed_conn.is_shutting_down()
returnsFalse
.Expected Result:
RuntimeError("Failed to send close message: muxed connection unavailable")
is raised.4. Muxed Connection Unavailable (During Shutdown)
Purpose: Confirm that no error is raised if the connection is unavailable but shutting down.
Test Setup:
send_message
to raiseMuxedConnUnavailable
.muxed_conn.is_shutting_down()
returnsTrue
.Expected Result:
5. Unexpected Exception During send_message
Purpose: Ensure that unexpected exceptions are surfaced correctly.
Test Setup:
send_message
to raise a generic exception (e.g., ValueError("boom")
).Expected Result:
Optional Utility:
You can also use
pytest-trio
andunittest.mock.AsyncMock
to easily simulate async behaviors.Beta Was this translation helpful? Give feedback.
All reactions