Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert return value of expected_http_error #1308

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions jupyter_server/services/events/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions tests/services/contents/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/services/events/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """\
Expand Down Expand Up @@ -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)