pywsitest icon indicating copy to clipboard operation
pywsitest copied to clipboard

[Question] Is it possible to print or log response on websocket handshake and message exchange?

Open 4nif opened this issue 5 years ago • 1 comments

I have try with_received_response_logging but can not see anything in the terminal.

Is it possible to print or log the response on websocket connect and message exchange to terminal with this library?

Thanks

4nif avatar Dec 27 '20 03:12 4nif

Hi,

with_received_response_logging is used to attach all received json responses to an exception when a test fails.

If you want to access the received responses when a test has completed and passed, you can print either received_responses or received_json.

await ws_test.run()
assert ws_test.is_complete()

for response in ws_test.received_responses:
    print(response)

We haven't yet added a way to log all responses as they arrive via the websocket connection as we primarily use this library in our CI pipeline, but that could be a very useful debugging feature to add.

If my response has helped, I'll change this from a bug to a feature request and see if we have time for it when we return to work in January.

jamsidedown avatar Dec 27 '20 18:12 jamsidedown