Skip to content

Commit d56f458

Browse files
committed
Migrate tests to ypy-websockets 13
1 parent da946b0 commit d56f458

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

tests/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ async def yws_server(request):
3232
kwargs = request.param
3333
except Exception:
3434
kwargs = {}
35+
3536
websocket_server = WebsocketServer(**kwargs)
36-
async with serve(websocket_server.serve, "localhost", 1234):
37-
yield websocket_server
37+
try:
38+
async with websocket_server, serve(websocket_server.serve, "localhost", 1234):
39+
yield websocket_server
40+
except Exception:
41+
pass
3842

3943

4044
@pytest.fixture

tests/test_ypy_yjs.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ def source(self):
5353
async def test_ypy_yjs_0(yws_server, yjs_client):
5454
ydoc = Y.YDoc()
5555
ynotebook = YNotebook(ydoc)
56-
websocket = await connect("ws://localhost:1234/my-roomname")
57-
WebsocketProvider(ydoc, websocket)
58-
nb = stringify_source(json.loads((files_dir / "nb0.ipynb").read_text()))
59-
ynotebook.source = nb
60-
ytest = YTest(ydoc, 3.0)
61-
await ytest.change()
62-
assert ytest.source == nb
56+
57+
async with connect("ws://localhost:1234/my-roomname") as websocket, WebsocketProvider(ydoc, websocket):
58+
nb = stringify_source(json.loads((files_dir / "nb0.ipynb").read_text()))
59+
ynotebook.source = nb
60+
ytest = YTest(ydoc, 3.0)
61+
await ytest.change()
62+
assert ytest.source == nb
6363

6464

6565
def test_plotly_renderer():

0 commit comments

Comments
 (0)