Skip to content

Commit 05e3532

Browse files
committed
add timeouts
1 parent 109f001 commit 05e3532

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

jupyter_server/tests/services/kernels/test_api.py

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
from jupyter_server.utils import url_path_join
1313

1414

15+
TEST_TIMEOUT = 20
16+
17+
1518
@pytest.fixture
1619
def pending_kernel_is_ready(jp_serverapp):
1720
async def _(kernel_id):
@@ -63,6 +66,7 @@ async def test_no_kernels(jp_fetch):
6366
assert kernels == []
6467

6568

69+
@pytest.mark.timeout(TEST_TIMEOUT)
6670
async def test_default_kernels(jp_fetch, jp_base_url, jp_cleanup_subprocesses):
6771
r = await jp_fetch("api", "kernels", method="POST", allow_nonstandard_methods=True)
6872
kernel = json.loads(r.body.decode())
@@ -78,6 +82,7 @@ async def test_default_kernels(jp_fetch, jp_base_url, jp_cleanup_subprocesses):
7882
await jp_cleanup_subprocesses()
7983

8084

85+
@pytest.mark.timeout(TEST_TIMEOUT)
8186
async def test_main_kernel_handler(
8287
jp_fetch, jp_base_url, jp_cleanup_subprocesses, jp_serverapp, pending_kernel_is_ready
8388
):
@@ -146,6 +151,7 @@ async def test_main_kernel_handler(
146151
await jp_cleanup_subprocesses()
147152

148153

154+
@pytest.mark.timeout(TEST_TIMEOUT)
149155
async def test_kernel_handler(jp_fetch, jp_cleanup_subprocesses, pending_kernel_is_ready):
150156
# Create a kernel
151157
r = await jp_fetch(
@@ -193,6 +199,7 @@ async def test_kernel_handler(jp_fetch, jp_cleanup_subprocesses, pending_kernel_
193199
await jp_cleanup_subprocesses()
194200

195201

202+
@pytest.mark.timeout(TEST_TIMEOUT)
196203
async def test_kernel_handler_startup_error(
197204
jp_fetch, jp_cleanup_subprocesses, jp_serverapp, jp_kernelspecs
198205
):
@@ -204,6 +211,7 @@ async def test_kernel_handler_startup_error(
204211
await jp_fetch("api", "kernels", method="POST", body=json.dumps({"name": "bad"}))
205212

206213

214+
@pytest.mark.timeout(TEST_TIMEOUT)
207215
async def test_kernel_handler_startup_error_pending(
208216
jp_fetch, jp_ws_fetch, jp_cleanup_subprocesses, jp_serverapp, jp_kernelspecs
209217
):
@@ -219,6 +227,7 @@ async def test_kernel_handler_startup_error_pending(
219227
await jp_ws_fetch("api", "kernels", kid, "channels")
220228

221229

230+
@pytest.mark.timeout(TEST_TIMEOUT)
222231
async def test_connection(
223232
jp_fetch, jp_ws_fetch, jp_http_port, jp_auth_header, jp_cleanup_subprocesses
224233
):

jupyter_server/tests/services/sessions/test_api.py

+18
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
from jupyter_server.utils import url_path_join
1818

1919

20+
TEST_TIMEOUT = 20
21+
22+
2023
j = lambda r: json.loads(r.body.decode())
2124

2225

@@ -197,6 +200,7 @@ def assert_session_equality(actual, expected):
197200
assert_kernel_equality(actual["kernel"], expected["kernel"])
198201

199202

203+
@pytest.mark.timeout(TEST_TIMEOUT)
200204
async def test_create(session_client, jp_base_url, jp_cleanup_subprocesses, jp_serverapp):
201205
# Make sure no sessions exist.
202206
resp = await session_client.list()
@@ -241,6 +245,7 @@ async def test_create(session_client, jp_base_url, jp_cleanup_subprocesses, jp_s
241245
await jp_cleanup_subprocesses()
242246

243247

248+
@pytest.mark.timeout(TEST_TIMEOUT)
244249
async def test_create_bad(
245250
session_client, jp_base_url, jp_cleanup_subprocesses, jp_serverapp, jp_kernelspecs
246251
):
@@ -261,6 +266,7 @@ async def test_create_bad(
261266
await jp_cleanup_subprocesses()
262267

263268

269+
@pytest.mark.timeout(TEST_TIMEOUT)
264270
async def test_create_bad_pending(
265271
session_client, jp_base_url, jp_ws_fetch, jp_cleanup_subprocesses, jp_serverapp, jp_kernelspecs
266272
):
@@ -293,6 +299,7 @@ async def test_create_bad_pending(
293299
await jp_cleanup_subprocesses()
294300

295301

302+
@pytest.mark.timeout(TEST_TIMEOUT)
296303
async def test_create_file_session(
297304
session_client, jp_cleanup_subprocesses, jp_serverapp, session_is_ready
298305
):
@@ -306,6 +313,7 @@ async def test_create_file_session(
306313
await jp_cleanup_subprocesses()
307314

308315

316+
@pytest.mark.timeout(TEST_TIMEOUT)
309317
async def test_create_console_session(
310318
session_client, jp_cleanup_subprocesses, jp_serverapp, session_is_ready
311319
):
@@ -320,6 +328,7 @@ async def test_create_console_session(
320328
await jp_cleanup_subprocesses()
321329

322330

331+
@pytest.mark.timeout(TEST_TIMEOUT)
323332
async def test_create_deprecated(session_client, jp_cleanup_subprocesses, jp_serverapp):
324333
resp = await session_client.create_deprecated("foo/nb1.ipynb")
325334
assert resp.code == 201
@@ -332,6 +341,7 @@ async def test_create_deprecated(session_client, jp_cleanup_subprocesses, jp_ser
332341
await jp_cleanup_subprocesses()
333342

334343

344+
@pytest.mark.timeout(TEST_TIMEOUT)
335345
async def test_create_with_kernel_id(
336346
session_client, jp_fetch, jp_base_url, jp_cleanup_subprocesses, jp_serverapp
337347
):
@@ -363,6 +373,7 @@ async def test_create_with_kernel_id(
363373
await jp_cleanup_subprocesses()
364374

365375

376+
@pytest.mark.timeout(TEST_TIMEOUT)
366377
async def test_create_with_bad_kernel_id(
367378
session_client, jp_cleanup_subprocesses, jp_serverapp, session_is_ready
368379
):
@@ -378,6 +389,7 @@ async def test_create_with_bad_kernel_id(
378389
await jp_cleanup_subprocesses()
379390

380391

392+
@pytest.mark.timeout(TEST_TIMEOUT)
381393
async def test_delete(session_client, jp_cleanup_subprocesses, jp_serverapp, session_is_ready):
382394
resp = await session_client.create("foo/nb1.ipynb")
383395

@@ -399,6 +411,7 @@ async def test_delete(session_client, jp_cleanup_subprocesses, jp_serverapp, ses
399411
await jp_cleanup_subprocesses()
400412

401413

414+
@pytest.mark.timeout(TEST_TIMEOUT)
402415
async def test_modify_path(session_client, jp_cleanup_subprocesses, jp_serverapp, session_is_ready):
403416
resp = await session_client.create("foo/nb1.ipynb")
404417
newsession = j(resp)
@@ -413,6 +426,7 @@ async def test_modify_path(session_client, jp_cleanup_subprocesses, jp_serverapp
413426
await jp_cleanup_subprocesses()
414427

415428

429+
@pytest.mark.timeout(TEST_TIMEOUT)
416430
async def test_modify_path_deprecated(
417431
session_client, jp_cleanup_subprocesses, jp_serverapp, session_is_ready
418432
):
@@ -429,6 +443,7 @@ async def test_modify_path_deprecated(
429443
await jp_cleanup_subprocesses()
430444

431445

446+
@pytest.mark.timeout(TEST_TIMEOUT)
432447
async def test_modify_type(session_client, jp_cleanup_subprocesses, jp_serverapp, session_is_ready):
433448
resp = await session_client.create("foo/nb1.ipynb")
434449
newsession = j(resp)
@@ -443,6 +458,7 @@ async def test_modify_type(session_client, jp_cleanup_subprocesses, jp_serverapp
443458
await jp_cleanup_subprocesses()
444459

445460

461+
@pytest.mark.timeout(TEST_TIMEOUT)
446462
async def test_modify_kernel_name(
447463
session_client, jp_fetch, jp_cleanup_subprocesses, jp_serverapp, session_is_ready
448464
):
@@ -470,6 +486,7 @@ async def test_modify_kernel_name(
470486
await jp_cleanup_subprocesses()
471487

472488

489+
@pytest.mark.timeout(TEST_TIMEOUT)
473490
async def test_modify_kernel_id(
474491
session_client, jp_fetch, jp_cleanup_subprocesses, jp_serverapp, session_is_ready
475492
):
@@ -504,6 +521,7 @@ async def test_modify_kernel_id(
504521
await jp_cleanup_subprocesses()
505522

506523

524+
@pytest.mark.timeout(TEST_TIMEOUT)
507525
async def test_restart_kernel(
508526
session_client, jp_base_url, jp_fetch, jp_ws_fetch, jp_cleanup_subprocesses, session_is_ready
509527
):

0 commit comments

Comments
 (0)