Skip to content

Commit a3a9d3d

Browse files
authored
Improve warning handling (jupyter-server#1386)
1 parent cfd7981 commit a3a9d3d

File tree

5 files changed

+29
-25
lines changed

5 files changed

+29
-25
lines changed

jupyter_server/services/contents/largefilemanager.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def save(self, model, path=""):
2020
path = path.strip("/")
2121

2222
if chunk == 1:
23-
self.run_pre_save_hook(model=model, path=path)
23+
self.run_pre_save_hooks(model=model, path=path)
2424

2525
if "type" not in model:
2626
raise web.HTTPError(400, "No file type provided")
@@ -92,7 +92,7 @@ async def save(self, model, path=""):
9292
path = path.strip("/")
9393

9494
if chunk == 1:
95-
self.run_pre_save_hook(model=model, path=path)
95+
self.run_pre_save_hooks(model=model, path=path)
9696

9797
if "type" not in model:
9898
raise web.HTTPError(400, "No file type provided")

pyproject.toml

+1-7
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,7 @@ timeout = 100
239239
timeout_method = "thread"
240240
filterwarnings = [
241241
"error",
242-
"ignore:Passing a schema to Validator.iter_errors:DeprecationWarning",
243-
"ignore:run_pre_save_hook is deprecated:DeprecationWarning",
244-
"always:unclosed <socket.socket:ResourceWarning",
245-
"module:Jupyter is migrating its paths to use standard platformdirs:DeprecationWarning",
246-
"ignore:jupyter_server.base.zmqhandlers module is deprecated in Jupyter Server 2.0:DeprecationWarning",
247-
"ignore:datetime.datetime.utc:DeprecationWarning:dateutil",
248-
"ignore:datetime.datetime.utc:DeprecationWarning:tornado",
242+
"ignore:datetime.datetime.utc:DeprecationWarning",
249243
"module:add_callback_from_signal is deprecated:DeprecationWarning",
250244
]
251245

tests/conftest.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import os
22

3+
# isort: off
4+
# This must come before any Jupyter imports.
5+
os.environ["JUPYTER_PLATFORM_DIRS"] = "1"
6+
# isort: on
7+
38
import pytest
49
from nbformat import writes
510
from nbformat.v4 import new_notebook

tests/extension/test_app.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import asyncio
12
import json
23
from io import StringIO
34
from logging import StreamHandler
45
from typing import Any
6+
from unittest import mock
57

68
import pytest
79
from traitlets.config import Config
@@ -121,12 +123,14 @@ def test_extensionapp_no_parent():
121123

122124
@pytest.mark.parametrize("expected_value, config", OPEN_BROWSER_COMBINATIONS)
123125
async def test_browser_open(monkeypatch, jp_environ, config, expected_value):
124-
serverapp = MockExtensionApp.initialize_server(config=Config(config))
126+
with mock.patch("jupyter_server.serverapp.ServerApp.init_httpserver"):
127+
serverapp = MockExtensionApp.initialize_server(config=Config(config))
125128
assert serverapp.open_browser == expected_value
126129

127130

128131
async def test_load_parallel_extensions(monkeypatch, jp_environ):
129-
serverapp = MockExtensionApp.initialize_server()
132+
with mock.patch("jupyter_server.serverapp.ServerApp.init_httpserver"):
133+
serverapp = MockExtensionApp.initialize_server()
130134
exts = serverapp.extension_manager.extensions
131135
assert "tests.extension.mockextensions.mock1" in exts
132136
assert "tests.extension.mockextensions" in exts

tests/test_gateway.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -715,20 +715,21 @@ async def test_websocket_connection_closed(init_gateway, jp_serverapp, jp_fetch,
715715
handler.ws_connection.is_closing = lambda: True
716716

717717
# Create the GatewayWebSocketConnection and attach it to the handler...
718-
conn = GatewayWebSocketConnection(parent=km, websocket_handler=handler)
719-
handler.connection = conn
720-
await conn.connect()
721-
722-
# Processing websocket messages happens in separate coroutines and any
723-
# errors in that process will show up in logs, but not bubble up to the
724-
# caller.
725-
#
726-
# To check for these, we wait for the server to stop and then check the
727-
# logs for errors.
728-
await jp_serverapp._cleanup()
729-
for _, level, message in caplog.record_tuples:
730-
if level >= logging.ERROR:
731-
pytest.fail(f"Logs contain an error: {message}")
718+
with mocked_gateway:
719+
conn = GatewayWebSocketConnection(parent=km, websocket_handler=handler)
720+
handler.connection = conn
721+
await conn.connect()
722+
723+
# Processing websocket messages happens in separate coroutines and any
724+
# errors in that process will show up in logs, but not bubble up to the
725+
# caller.
726+
#
727+
# To check for these, we wait for the server to stop and then check the
728+
# logs for errors.
729+
await jp_serverapp._cleanup()
730+
for _, level, message in caplog.record_tuples:
731+
if level >= logging.ERROR:
732+
pytest.fail(f"Logs contain an error: {message}")
732733

733734

734735
#

0 commit comments

Comments
 (0)