Skip to content

Commit f6f8c3f

Browse files
authored
Add explicit handling of warnings (#771)
* add explicit handling of warnings * ignore warning on min version test * fix process shutdown * fix remaining warnings * fixup * add cleanup_suprocesses
1 parent 25ec3ed commit f6f8c3f

File tree

9 files changed

+36
-20
lines changed

9 files changed

+36
-20
lines changed

.github/workflows/python-tests.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ jobs:
3333
- name: Run the tests
3434
if: ${{ !startsWith(matrix.python-version, 'pypy') && !startsWith(matrix.os, 'windows') }}
3535
run: |
36-
args="-vv --cov jupyter_server --cov-branch --cov-report term-missing:skip-covered --cov-fail-under 70"
37-
python -m pytest $args || python -m pytest $args --lf
36+
args="-vv --cov jupyter_server --cov-branch --cov-report term-missing:skip-covered"
37+
python -m pytest $args --cov-fail-under 70 || python -m pytest $args --lf
3838
- name: Run the tests on pypy and windows
3939
if: ${{ startsWith(matrix.python-version, 'pypy') || startsWith(matrix.os, 'windows') }}
4040
run: |
@@ -78,7 +78,7 @@ jobs:
7878
uses: jupyterlab/maintainer-tools/.github/actions/install-minimums@v1
7979
- name: Run the unit tests
8080
run: |
81-
pytest -vv || pytest -vv --lf
81+
pytest -vv -W default || pytest -vv -W default --lf
8282
8383
test_prereleases:
8484
name: Test Prereleases

docs/source/operators/multiple-extensions.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ Extensions can also be enabled manually from the Jupyter Server entrypoint using
9090

9191
.. code-block:: console
9292
93-
> jupyter server --ServerApp.jpserver_extensions='{"myextension":{"enabled": True}}'
93+
> jupyter server --ServerApp.jpserver_extensions="myextension=True"

jupyter_server/pytest_plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def client_fetch(*parts, headers=None, params=None, **kwargs):
415415
@pytest.fixture
416416
def jp_kernelspecs(jp_data_dir):
417417
"""Configures some sample kernelspecs in the Jupyter data directory."""
418-
spec_names = ["sample", "sample 2", "bad"]
418+
spec_names = ["sample", "sample2", "bad"]
419419
for name in spec_names:
420420
sample_kernel_dir = jp_data_dir.joinpath("kernels", name)
421421
sample_kernel_dir.mkdir(parents=True)

pyproject.toml

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ testpaths = [
1616
timeout = 300
1717
# Restore this setting to debug failures
1818
# timeout_method = "thread"
19+
filterwarnings = [
20+
"error",
21+
"ignore:There is no current event loop:DeprecationWarning",
22+
"ignore:Passing a schema to Validator.iter_errors:DeprecationWarning",
23+
"ignore:unclosed <socket.socket:ResourceWarning",
24+
"ignore:unclosed event loop:ResourceWarning",
25+
"ignore:run_pre_save_hook is deprecated:DeprecationWarning"
26+
]
1927

2028
[tool.jupyter-releaser]
2129
skip = ["check-links"]

tests/auth/test_authorizer.py

+3
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ async def test_authorized_requests(
205205
send_request,
206206
tmp_path,
207207
jp_serverapp,
208+
jp_cleanup_subprocesses,
208209
method,
209210
url,
210211
body,
@@ -274,3 +275,5 @@ async def test_authorized_requests(
274275

275276
code = await send_request(url, body=body, method=method)
276277
assert code in expected_codes
278+
279+
await jp_cleanup_subprocesses()

tests/extension/test_launch.py

+5
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ def _kill_extension_app():
5454
# Already dead.
5555
pass
5656
process.wait(10)
57+
# Make sure all the fds get closed.
58+
for attr in ["stdout", "stderr", "stdin"]:
59+
fid = getattr(process, attr)
60+
if fid:
61+
fid.close()
5762

5863
if add_token:
5964
f'--ServerApp.token="{token}"',

tests/extension/test_serverextension.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,11 @@ def test_merge_config(jp_env_config_path, jp_configurable_serverapp, jp_extensio
7171
user=True,
7272
)
7373

74-
arg = "--ServerApp.jpserver_extensions={{'{mockext_py}': True}}".format(
75-
mockext_py="tests.extension.mockextensions.mockext_py"
76-
)
74+
mockext_py = "tests.extension.mockextensions.mockext_py"
75+
argv = ["--ServerApp.jpserver_extensions", f"{mockext_py}=True"]
7776

7877
# Enable the last extension, mockext_py, using the CLI interface.
79-
app = jp_configurable_serverapp(config_dir=str(jp_env_config_path), argv=[arg])
78+
app = jp_configurable_serverapp(config_dir=str(jp_env_config_path), argv=argv)
8079
# Verify that extensions are enabled and merged in proper order.
8180
extensions = app.jpserver_extensions
8281
assert extensions["tests.extension.mockextensions.mockext_user"]

tests/services/kernelspecs/test_api.py

-6
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ async def test_get_kernelspecs(jp_fetch, jp_kernelspecs):
5050
assert isinstance(model["resources"], dict)
5151

5252

53-
async def test_get_kernelspec_spaces(jp_fetch, jp_kernelspecs):
54-
r = await jp_fetch("api", "kernelspecs", "sample%202", method="GET")
55-
model = json.loads(r.body.decode())
56-
assert model["name"].lower() == "sample 2"
57-
58-
5953
async def test_get_nonexistant_kernelspec(jp_fetch, jp_kernelspecs):
6054
with pytest.raises(tornado.httpclient.HTTPClientError) as e:
6155
await jp_fetch("api", "kernelspecs", "nonexistant", method="GET")

tests/unix_sockets/test_serverapp_integration.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515
from jupyter_server.utils import urlencode_unix_socket, urlencode_unix_socket_path
1616

1717

18+
def _cleanup_process(proc):
19+
proc.wait()
20+
# Make sure all the fds get closed.
21+
for attr in ["stdout", "stderr", "stdin"]:
22+
fid = getattr(proc, attr)
23+
if fid:
24+
fid.close()
25+
26+
1827
@pytest.mark.integration_test
1928
def test_shutdown_sock_server_integration(jp_unix_socket_file):
2029
url = urlencode_unix_socket(jp_unix_socket_file).encode()
@@ -52,7 +61,7 @@ def test_shutdown_sock_server_integration(jp_unix_socket_file):
5261

5362
assert encoded_sock_path.encode() not in subprocess.check_output(["jupyter-server", "list"])
5463

55-
p.wait()
64+
_cleanup_process(p)
5665

5766

5867
@pytest.mark.integration_test
@@ -129,9 +138,7 @@ def test_stop_multi_integration(jp_unix_socket_file, jp_http_port):
129138

130139
_ensure_stopped()
131140

132-
p1.wait()
133-
p2.wait()
134-
p3.wait()
141+
[_cleanup_process(p) for p in [p1, p2, p3]]
135142

136143

137144
@pytest.mark.integration_test
@@ -162,4 +169,4 @@ def test_launch_socket_collision(jp_unix_socket_file):
162169

163170
_ensure_stopped()
164171

165-
p1.wait()
172+
_cleanup_process(p1)

0 commit comments

Comments
 (0)