Skip to content

Instantly share code, notes, and snippets.

@ir4y
Created February 13, 2014 18:41
Show Gist options
  • Select an option

  • Save ir4y/8981172 to your computer and use it in GitHub Desktop.

Select an option

Save ir4y/8981172 to your computer and use it in GitHub Desktop.
import pytest
from websocket import create_connection
@pytest.fixture(scope="module")
def ws(request):
ws = create_connection("ws://localhost:8080/bullet")
def fin():
ws.close()
request.addfinalizer(fin)
return ws
def test_echo(ws):
ws.send("Hello, World")
result = ws.recv()
assert result == "Hello, World"
def test_fail(ws):
ws.send("Hello, World")
result = ws.recv()
assert result == "Hello, World1"
def test_get_time(ws):
result = ws.recv()
assert isinstance(result, str)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment