Skip to content

Commit 6744736

Browse files
committed
Make test_execute more robust
1 parent 9a5b56b commit 6744736

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ test = [
6565
"types-setuptools",
6666
"pytest",
6767
"pytest-timeout",
68+
"pytest-rerunfailures",
6869
"pytest-env",
6970
"httpx",
7071
"httpx-ws >=0.4.1",

tests/test_execute.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ async def recv(self) -> bytes:
8686

8787

8888
@pytest.mark.anyio
89+
@pytest.mark.flaky(reruns=2)
8990
@pytest.mark.parametrize("auth_mode", ("noauth",))
9091
async def test_execute(auth_mode, unused_tcp_port):
9192
url = f"http://127.0.0.1:{unused_tcp_port}"
@@ -152,7 +153,11 @@ def callback(aevent, events, event):
152153
):
153154
# connect to the shared notebook document
154155
# wait for file to be loaded and Y model to be created in server and client
155-
await anyio.sleep(0.5)
156+
with anyio.fail_after(1):
157+
while True:
158+
if len(ynb.ycells) >= 2:
159+
break
160+
await anyio.sleep(0.1)
156161
# execute notebook
157162
for cell_idx in range(2):
158163
response = await http.post(

tests/test_server.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,11 @@ def callback(aevent, events, event):
175175
):
176176
# connect to the shared notebook document
177177
# wait for file to be loaded and Y model to be created in server and client
178-
await anyio.sleep(0.5)
178+
with anyio.fail_after(1):
179+
while True:
180+
if len(ynb.ycells) >= 2:
181+
break
182+
await anyio.sleep(0.1)
179183
# execute notebook
180184
for cell_idx in range(2):
181185
response = requests.post(

0 commit comments

Comments
 (0)