diff --git a/jupyter_server/services/events/handlers.py b/jupyter_server/services/events/handlers.py index 8bd533b55e..3f3a5c64c2 100644 --- a/jupyter_server/services/events/handlers.py +++ b/jupyter_server/services/events/handlers.py @@ -110,6 +110,8 @@ async def post(self): ) self.set_status(204) self.finish() + except web.HTTPError: + raise except Exception as e: raise web.HTTPError(500, str(e)) from e diff --git a/tests/services/contents/test_manager.py b/tests/services/contents/test_manager.py index 9871cc9b1d..7fa5cbd742 100644 --- a/tests/services/contents/test_manager.py +++ b/tests/services/contents/test_manager.py @@ -448,19 +448,19 @@ async def test_escape_root(jp_file_contents_manager_class, tmp_path): with pytest.raises(HTTPError) as e: await ensure_async(cm.get("..")) - expected_http_error(e, 404) + assert expected_http_error(e, 404) with pytest.raises(HTTPError) as e: await ensure_async(cm.get("foo/../../../bar")) - expected_http_error(e, 404) + assert expected_http_error(e, 404) with pytest.raises(HTTPError) as e: await ensure_async(cm.delete("../foo")) - expected_http_error(e, 404) + assert expected_http_error(e, 404) with pytest.raises(HTTPError) as e: await ensure_async(cm.rename("../foo", "../bar")) - expected_http_error(e, 404) + assert expected_http_error(e, 404) with pytest.raises(HTTPError) as e: await ensure_async( @@ -473,7 +473,7 @@ async def test_escape_root(jp_file_contents_manager_class, tmp_path): path="../foo", ) ) - expected_http_error(e, 404) + assert expected_http_error(e, 404) async def test_new_untitled(jp_contents_manager): diff --git a/tests/services/events/test_api.py b/tests/services/events/test_api.py index 017b7c942e..5311f0860b 100644 --- a/tests/services/events/test_api.py +++ b/tests/services/events/test_api.py @@ -123,7 +123,7 @@ async def test_post_event_400(jp_fetch, event_logger, payload): with pytest.raises(tornado.httpclient.HTTPClientError) as e: await jp_fetch("api", "events", method="POST", body=payload) - expected_http_error(e, 400) + assert expected_http_error(e, 400) payload_7 = """\ @@ -152,4 +152,4 @@ async def test_post_event_500(jp_fetch, event_logger, payload): with pytest.raises(tornado.httpclient.HTTPClientError) as e: await jp_fetch("api", "events", method="POST", body=payload) - expected_http_error(e, 500) + assert expected_http_error(e, 500)