@@ -1250,34 +1250,22 @@ async def test_writing_in_send_context_fails(self):
12501250
12511251 # Test safety nets — catching all exceptions in case of bugs.
12521252
1253- # Inject a fault in a random call in data_received().
1254- # This test is tightly coupled to the implementation.
12551253 @patch ("websockets.protocol.Protocol.events_received" , side_effect = AssertionError )
12561254 async def test_unexpected_failure_in_data_received (self , events_received ):
12571255 """Unexpected internal error in data_received() is correctly reported."""
1258- # Receive a message to trigger the fault.
12591256 await self .remote_connection .send ("😀" )
1260-
12611257 with self .assertRaises (ConnectionClosedError ) as raised :
12621258 await self .connection .recv ()
1259+ self .assertIsInstance (raised .exception .__cause__ , AssertionError )
12631260
1264- exc = raised .exception
1265- self .assertEqual (str (exc ), "no close frame received or sent" )
1266- self .assertIsInstance (exc .__cause__ , AssertionError )
1267-
1268- # Inject a fault in a random call in send_context().
1269- # This test is tightly coupled to the implementation.
12701261 @patch ("websockets.protocol.Protocol.send_text" , side_effect = AssertionError )
12711262 async def test_unexpected_failure_in_send_context (self , send_text ):
12721263 """Unexpected internal error in send_context() is correctly reported."""
12731264 # Send a message to trigger the fault.
12741265 # The connection closed exception reports the injected fault.
12751266 with self .assertRaises (ConnectionClosedError ) as raised :
12761267 await self .connection .send ("😀" )
1277-
1278- exc = raised .exception
1279- self .assertEqual (str (exc ), "no close frame received or sent" )
1280- self .assertIsInstance (exc .__cause__ , AssertionError )
1268+ self .assertIsInstance (raised .exception .__cause__ , AssertionError )
12811269
12821270 # Test broadcast.
12831271
0 commit comments