Skip to content

Commit

Permalink
Add explicit handling of warnings (#771)
Browse files Browse the repository at this point in the history
* add explicit handling of warnings

* ignore warning on min version test

* fix process shutdown

* fix remaining warnings

* fixup

* add cleanup_suprocesses
  • Loading branch information
blink1073 authored Apr 2, 2022
1 parent 25ec3ed commit f6f8c3f
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
- name: Run the tests
if: ${{ !startsWith(matrix.python-version, 'pypy') && !startsWith(matrix.os, 'windows') }}
run: |
args="-vv --cov jupyter_server --cov-branch --cov-report term-missing:skip-covered --cov-fail-under 70"
python -m pytest $args || python -m pytest $args --lf
args="-vv --cov jupyter_server --cov-branch --cov-report term-missing:skip-covered"
python -m pytest $args --cov-fail-under 70 || python -m pytest $args --lf
- name: Run the tests on pypy and windows
if: ${{ startsWith(matrix.python-version, 'pypy') || startsWith(matrix.os, 'windows') }}
run: |
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
uses: jupyterlab/maintainer-tools/.github/actions/install-minimums@v1
- name: Run the unit tests
run: |
pytest -vv || pytest -vv --lf
pytest -vv -W default || pytest -vv -W default --lf
test_prereleases:
name: Test Prereleases
Expand Down
2 changes: 1 addition & 1 deletion docs/source/operators/multiple-extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ Extensions can also be enabled manually from the Jupyter Server entrypoint using

.. code-block:: console
> jupyter server --ServerApp.jpserver_extensions='{"myextension":{"enabled": True}}'
> jupyter server --ServerApp.jpserver_extensions="myextension=True"
2 changes: 1 addition & 1 deletion jupyter_server/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def client_fetch(*parts, headers=None, params=None, **kwargs):
@pytest.fixture
def jp_kernelspecs(jp_data_dir):
"""Configures some sample kernelspecs in the Jupyter data directory."""
spec_names = ["sample", "sample 2", "bad"]
spec_names = ["sample", "sample2", "bad"]
for name in spec_names:
sample_kernel_dir = jp_data_dir.joinpath("kernels", name)
sample_kernel_dir.mkdir(parents=True)
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ testpaths = [
timeout = 300
# Restore this setting to debug failures
# timeout_method = "thread"
filterwarnings = [
"error",
"ignore:There is no current event loop:DeprecationWarning",
"ignore:Passing a schema to Validator.iter_errors:DeprecationWarning",
"ignore:unclosed <socket.socket:ResourceWarning",
"ignore:unclosed event loop:ResourceWarning",
"ignore:run_pre_save_hook is deprecated:DeprecationWarning"
]

[tool.jupyter-releaser]
skip = ["check-links"]
Expand Down
3 changes: 3 additions & 0 deletions tests/auth/test_authorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ async def test_authorized_requests(
send_request,
tmp_path,
jp_serverapp,
jp_cleanup_subprocesses,
method,
url,
body,
Expand Down Expand Up @@ -274,3 +275,5 @@ async def test_authorized_requests(

code = await send_request(url, body=body, method=method)
assert code in expected_codes

await jp_cleanup_subprocesses()
5 changes: 5 additions & 0 deletions tests/extension/test_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ def _kill_extension_app():
# Already dead.
pass
process.wait(10)
# Make sure all the fds get closed.
for attr in ["stdout", "stderr", "stdin"]:
fid = getattr(process, attr)
if fid:
fid.close()

if add_token:
f'--ServerApp.token="{token}"',
Expand Down
7 changes: 3 additions & 4 deletions tests/extension/test_serverextension.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,11 @@ def test_merge_config(jp_env_config_path, jp_configurable_serverapp, jp_extensio
user=True,
)

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

# Enable the last extension, mockext_py, using the CLI interface.
app = jp_configurable_serverapp(config_dir=str(jp_env_config_path), argv=[arg])
app = jp_configurable_serverapp(config_dir=str(jp_env_config_path), argv=argv)
# Verify that extensions are enabled and merged in proper order.
extensions = app.jpserver_extensions
assert extensions["tests.extension.mockextensions.mockext_user"]
Expand Down
6 changes: 0 additions & 6 deletions tests/services/kernelspecs/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ async def test_get_kernelspecs(jp_fetch, jp_kernelspecs):
assert isinstance(model["resources"], dict)


async def test_get_kernelspec_spaces(jp_fetch, jp_kernelspecs):
r = await jp_fetch("api", "kernelspecs", "sample%202", method="GET")
model = json.loads(r.body.decode())
assert model["name"].lower() == "sample 2"


async def test_get_nonexistant_kernelspec(jp_fetch, jp_kernelspecs):
with pytest.raises(tornado.httpclient.HTTPClientError) as e:
await jp_fetch("api", "kernelspecs", "nonexistant", method="GET")
Expand Down
17 changes: 12 additions & 5 deletions tests/unix_sockets/test_serverapp_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
from jupyter_server.utils import urlencode_unix_socket, urlencode_unix_socket_path


def _cleanup_process(proc):
proc.wait()
# Make sure all the fds get closed.
for attr in ["stdout", "stderr", "stdin"]:
fid = getattr(proc, attr)
if fid:
fid.close()


@pytest.mark.integration_test
def test_shutdown_sock_server_integration(jp_unix_socket_file):
url = urlencode_unix_socket(jp_unix_socket_file).encode()
Expand Down Expand Up @@ -52,7 +61,7 @@ def test_shutdown_sock_server_integration(jp_unix_socket_file):

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

p.wait()
_cleanup_process(p)


@pytest.mark.integration_test
Expand Down Expand Up @@ -129,9 +138,7 @@ def test_stop_multi_integration(jp_unix_socket_file, jp_http_port):

_ensure_stopped()

p1.wait()
p2.wait()
p3.wait()
[_cleanup_process(p) for p in [p1, p2, p3]]


@pytest.mark.integration_test
Expand Down Expand Up @@ -162,4 +169,4 @@ def test_launch_socket_collision(jp_unix_socket_file):

_ensure_stopped()

p1.wait()
_cleanup_process(p1)

0 comments on commit f6f8c3f

Please sign in to comment.