@@ -78,27 +78,33 @@ async def receive_from(self, timeout=1):
7878 """
7979 response = await self .receive_output (timeout )
8080 # Make sure this is a send message
81- assert response ["type" ] == "websocket.send"
81+ assert (
82+ response ["type" ] == "websocket.send"
83+ ), f"Expected type 'websocket.send', but was '{ response ['type' ]} '"
8284 # Make sure there's exactly one key in the response
8385 assert ("text" in response ) != (
8486 "bytes" in response
8587 ), "The response needs exactly one of 'text' or 'bytes'"
8688 # Pull out the right key and typecheck it for our users
8789 if "text" in response :
88- assert isinstance (response ["text" ], str ), "Text frame payload is not str"
90+ assert isinstance (
91+ response ["text" ], str
92+ ), f"Text frame payload is not str, it is { type (response ['text' ])} "
8993 return response ["text" ]
9094 else :
9195 assert isinstance (
9296 response ["bytes" ], bytes
93- ), "Binary frame payload is not bytes"
97+ ), f "Binary frame payload is not bytes, it is { type ( response [ 'bytes' ]) } "
9498 return response ["bytes" ]
9599
96100 async def receive_json_from (self , timeout = 1 ):
97101 """
98102 Receives a JSON text frame payload and decodes it
99103 """
100104 payload = await self .receive_from (timeout )
101- assert isinstance (payload , str ), "JSON data is not a text frame"
105+ assert isinstance (
106+ payload , str
107+ ), f"JSON data is not a text frame, it is { type (payload )} "
102108 return json .loads (payload )
103109
104110 async def disconnect (self , code = 1000 , timeout = 1 ):
0 commit comments