pytest-play support for websockets
More info and examples on:
- pytest-play, documentation
- cookiecutter-qa, see
pytest-playin action with a working example if you want to start hacking
This project defines new pytest-play commands.
- type: connect
provider: play_websocket
options:
url: wss://echo.websocket.org/
timeout: 2
- type: send provider: play_websocket url: wss://echo.websocket.org/ payload: Hello!
- type: recv provider: play_websocket url: wss://echo.websocket.org/ variable: data variable_expression: response.upper() assertion: data == 'HELLO!' timeout: 10
If you want to filter the data returned by the websocked until you get what you expect:
- provider: python
type: wait_until
expression: variables['data'] == 'HELLO!'
timeout: 60
poll: 0
sub_commands:
- type: recv
provider: play_websocket
url: wss://echo.websocket.org/
variable: data
variable_expression: response.upper()
timeout: 60
pytest-play tweets happens here:
This package was created with Cookiecutter and the cookiecutter-play-plugin (based on audreyr/cookiecutter-pypackage project template).