Skip to content

Commit 5838917

Browse files
authored
Restore public api names (#32)
1 parent 72daff8 commit 5838917

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

pytest_jupyter/jupyter_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def jp_asyncio_loop():
4646

4747

4848
@pytest.fixture(autouse=True)
49-
def jp_io_loop(jp_asyncio_loop):
49+
def io_loop(jp_asyncio_loop):
5050
"""Override the io_loop for pytest_tornasync. This is a no-op
5151
if tornado is not installed."""
5252

pytest_jupyter/jupyter_server.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,22 @@
5353

5454

5555
@pytest.fixture
56-
def jp_http_server(jp_io_loop, jp_http_server_port, jp_web_app):
56+
def http_server(io_loop, http_server_port, jp_web_app):
5757
"""Start a tornado HTTP server that listens on all available interfaces."""
5858

5959
async def get_server():
6060
server = tornado.httpserver.HTTPServer(jp_web_app)
61-
server.add_socket(jp_http_server_port[0])
61+
server.add_socket(http_server_port[0])
6262
return server
6363

64-
server = jp_io_loop.run_sync(get_server)
64+
server = io_loop.run_sync(get_server)
6565
yield server
6666
server.stop()
6767

6868
if hasattr(server, "close_all_connections"):
69-
jp_io_loop.run_sync(server.close_all_connections)
69+
io_loop.run_sync(server.close_all_connections)
7070

71-
jp_http_server_port[0].close()
71+
http_server_port[0].close()
7272

7373

7474
# End pytest_tornasync overrides
@@ -107,10 +107,10 @@ def jp_argv():
107107

108108

109109
@pytest.fixture()
110-
def jp_http_port(jp_http_server_port):
110+
def http_port(http_server_port):
111111
"""Returns the port value from the http_server_port fixture."""
112-
yield jp_http_server_port[-1]
113-
jp_http_server_port[0].close()
112+
yield http_server_port[-1]
113+
http_server_port[0].close()
114114

115115

116116
@pytest.fixture
@@ -161,13 +161,13 @@ def jp_configurable_serverapp(
161161
jp_environ,
162162
jp_server_config,
163163
jp_argv,
164-
jp_http_port,
164+
http_port,
165165
jp_base_url,
166166
tmp_path,
167167
jp_root_dir,
168168
jp_logging_stream,
169169
jp_asyncio_loop,
170-
jp_io_loop,
170+
io_loop,
171171
):
172172
"""Starts a Jupyter Server instance based on
173173
the provided configuration values.
@@ -195,9 +195,9 @@ def _configurable_serverapp(
195195
base_url=jp_base_url,
196196
argv=jp_argv,
197197
environ=jp_environ,
198-
http_port=jp_http_port,
198+
http_port=http_port,
199199
tmp_path=tmp_path,
200-
io_loop=jp_io_loop,
200+
io_loop=io_loop,
201201
root_dir=jp_root_dir,
202202
**kwargs,
203203
):
@@ -282,7 +282,7 @@ def jp_base_url():
282282

283283

284284
@pytest.fixture
285-
def jp_fetch(jp_serverapp, jp_http_server_client, jp_auth_header, jp_base_url):
285+
def jp_fetch(jp_serverapp, http_server_client, jp_auth_header, jp_base_url):
286286
"""Sends an (asynchronous) HTTP request to a test server.
287287
The fixture is a factory; it can be called like
288288
a function inside a unit test. Here's a basic
@@ -309,13 +309,13 @@ def client_fetch(*parts, headers=None, params=None, **kwargs):
309309
for key, value in jp_auth_header.items():
310310
headers.setdefault(key, value)
311311
# Make request.
312-
return jp_http_server_client.fetch(url, headers=headers, request_timeout=20, **kwargs)
312+
return http_server_client.fetch(url, headers=headers, request_timeout=20, **kwargs)
313313

314314
return client_fetch
315315

316316

317317
@pytest.fixture
318-
def jp_ws_fetch(jp_serverapp, jp_http_server_client, jp_auth_header, jp_http_port, jp_base_url):
318+
def jp_ws_fetch(jp_serverapp, http_server_client, jp_auth_header, http_port, jp_base_url):
319319
"""Sends a websocket request to a test server.
320320
The fixture is a factory; it can be called like
321321
a function inside a unit test. Here's a basic
@@ -348,7 +348,7 @@ def client_fetch(*parts, headers=None, params=None, **kwargs):
348348
# Handle URL strings
349349
path_url = url_escape(url_path_join(*parts), plus=False)
350350
base_path_url = url_path_join(jp_base_url, path_url)
351-
urlparts = urllib.parse.urlparse(f"ws://localhost:{jp_http_port}")
351+
urlparts = urllib.parse.urlparse(f"ws://localhost:{http_port}")
352352
urlparts = urlparts._replace(path=base_path_url, query=urllib.parse.urlencode(params))
353353
url = urlparts.geturl()
354354
# Add auth keys to header

pytest_jupyter/pytest_tornasync.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def pytest_pyfunc_call(pyfuncitem):
3030
return True
3131

3232
try:
33-
loop = funcargs["jp_io_loop"]
33+
loop = funcargs["io_loop"]
3434
except KeyError:
3535
loop = tornado.ioloop.IOLoop.current()
3636

@@ -39,23 +39,23 @@ def pytest_pyfunc_call(pyfuncitem):
3939

4040

4141
@pytest.fixture
42-
def jp_http_server_port():
42+
def http_server_port():
4343
"""
4444
Port used by `http_server`.
4545
"""
4646
return tornado.testing.bind_unused_port()
4747

4848

4949
@pytest.fixture
50-
def jp_http_server_client(jp_http_server, jp_io_loop):
50+
def http_server_client(http_server, io_loop):
5151
"""
5252
Create an asynchronous HTTP client that can fetch from `http_server`.
5353
"""
5454

5555
async def get_client():
56-
return AsyncHTTPServerClient(http_server=jp_http_server)
56+
return AsyncHTTPServerClient(http_server=http_server)
5757

58-
client = jp_io_loop.run_sync(get_client)
58+
client = io_loop.run_sync(get_client)
5959
with closing(client) as context:
6060
yield context
6161

tests/test_jupyter_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async def test_send_request(send_request):
2121
assert code == 200
2222

2323

24-
async def test_connection(jp_fetch, jp_ws_fetch, jp_http_port, jp_auth_header):
24+
async def test_connection(jp_fetch, jp_ws_fetch, http_port, jp_auth_header):
2525
# Create kernel
2626
r = await jp_fetch("api", "kernels", method="POST", body="{}")
2727
kid = json.loads(r.body.decode())["id"]

0 commit comments

Comments
 (0)