Skip to content

Commit 83d5ae1

Browse files
authored
Allow strict mode usage (#24)
1 parent f0c77e2 commit 83d5ae1

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ addopts = "-raXs --durations 10 --color=yes --doctest-modules"
8989
testpaths = [
9090
"tests"
9191
]
92-
asyncio_mode = "auto"
92+
asyncio_mode = "strict"
9393
timeout = 10
9494
# Restore this setting to debug failures
9595
timeout_method = "thread"

pytest_jupyter/jupyter_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pathlib import Path
88

99
import pytest
10+
import pytest_asyncio
1011
from jupyter_core import paths
1112

1213
try:
@@ -55,7 +56,7 @@ def zmq_context():
5556
ctx.term()
5657

5758

58-
@pytest.fixture
59+
@pytest_asyncio.fixture
5960
async def start_kernel(echo_kernel_spec):
6061
kms = []
6162
kcs = []

pytest_jupyter/jupyter_server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import jupyter_core.paths
1616
import pytest
17+
import pytest_asyncio
1718

1819
# The try block is needed so that the documentation can
1920
# still build without needed to install all the dependencies.
@@ -51,7 +52,7 @@
5152
pytest_plugins = ["pytest_tornasync", "pytest_jupyter.jupyter_client"]
5253

5354

54-
@pytest.fixture
55+
@pytest_asyncio.fixture
5556
async def asyncio_loop():
5657
return asyncio.get_running_loop()
5758

tests/test_jupyter_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from unittest.mock import Mock
22

3+
import pytest
34
from jupyter_client.session import Session
45

56
from pytest_jupyter.echo_kernel import EchoKernel
@@ -9,6 +10,7 @@ def test_zmq_context(zmq_context):
910
assert isinstance(zmq_context.underlying, int)
1011

1112

13+
@pytest.mark.asyncio
1214
async def test_start_kernel(start_kernel):
1315
km, kc = await start_kernel()
1416
assert km.kernel_name == "echo"

tests/test_jupyter_server.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,30 @@
22
import os
33
from unittest.mock import MagicMock
44

5+
import pytest
56
from jupyter_server.auth import Authorizer
67
from jupyter_server.serverapp import ServerApp
78
from tornado.websocket import WebSocketHandler
89

910

11+
@pytest.mark.asyncio
1012
async def test_serverapp(jp_serverapp):
1113
assert isinstance(jp_serverapp, ServerApp)
1214

1315

16+
@pytest.mark.asyncio
1417
async def test_get_api_spec(jp_fetch):
1518
response = await jp_fetch("api", "spec.yaml", method="GET")
1619
assert response.code == 200
1720

1821

22+
@pytest.mark.asyncio
1923
async def test_send_request(send_request):
2024
code = await send_request("api/spec.yaml", method="GET")
2125
assert code == 200
2226

2327

28+
@pytest.mark.asyncio
2429
async def test_connection(jp_fetch, jp_ws_fetch, jp_http_port, jp_auth_header):
2530
# Create kernel
2631
r = await jp_fetch("api", "kernels", method="POST", body="{}")
@@ -36,6 +41,7 @@ async def test_connection(jp_fetch, jp_ws_fetch, jp_http_port, jp_auth_header):
3641
ws.close()
3742

3843

44+
@pytest.mark.asyncio
3945
async def test_authorizer(jp_server_authorizer, jp_serverapp, jp_base_url):
4046
auth: Authorizer = jp_server_authorizer(parent=jp_serverapp)
4147
assert isinstance(auth, Authorizer)
@@ -50,6 +56,7 @@ async def test_authorizer(jp_server_authorizer, jp_serverapp, jp_base_url):
5056
assert auth.match_url_to_resource("/api/shutdown") == "server"
5157

5258

59+
@pytest.mark.asyncio
5360
async def test_create_notebook(jp_create_notebook):
5461
nb = jp_create_notebook("foo.ipynb")
5562
assert "nbformat" in nb

0 commit comments

Comments
 (0)