From a3a9d3deea7a798d13fe09a41e53f6f825caf21b Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 16 Jan 2024 08:41:54 -0600 Subject: [PATCH] Improve warning handling (#1386) --- .../services/contents/largefilemanager.py | 4 +-- pyproject.toml | 8 +---- tests/conftest.py | 5 ++++ tests/extension/test_app.py | 8 +++-- tests/test_gateway.py | 29 ++++++++++--------- 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/jupyter_server/services/contents/largefilemanager.py b/jupyter_server/services/contents/largefilemanager.py index bb66b57758..938206100f 100644 --- a/jupyter_server/services/contents/largefilemanager.py +++ b/jupyter_server/services/contents/largefilemanager.py @@ -20,7 +20,7 @@ def save(self, model, path=""): path = path.strip("/") if chunk == 1: - self.run_pre_save_hook(model=model, path=path) + self.run_pre_save_hooks(model=model, path=path) if "type" not in model: raise web.HTTPError(400, "No file type provided") @@ -92,7 +92,7 @@ async def save(self, model, path=""): path = path.strip("/") if chunk == 1: - self.run_pre_save_hook(model=model, path=path) + self.run_pre_save_hooks(model=model, path=path) if "type" not in model: raise web.HTTPError(400, "No file type provided") diff --git a/pyproject.toml b/pyproject.toml index aaf768627a..be3a03d49b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -239,13 +239,7 @@ timeout = 100 timeout_method = "thread" filterwarnings = [ "error", - "ignore:Passing a schema to Validator.iter_errors:DeprecationWarning", - "ignore:run_pre_save_hook is deprecated:DeprecationWarning", - "always:unclosed = logging.ERROR: - pytest.fail(f"Logs contain an error: {message}") + with mocked_gateway: + conn = GatewayWebSocketConnection(parent=km, websocket_handler=handler) + handler.connection = conn + await conn.connect() + + # Processing websocket messages happens in separate coroutines and any + # errors in that process will show up in logs, but not bubble up to the + # caller. + # + # To check for these, we wait for the server to stop and then check the + # logs for errors. + await jp_serverapp._cleanup() + for _, level, message in caplog.record_tuples: + if level >= logging.ERROR: + pytest.fail(f"Logs contain an error: {message}") #