Skip to content

Commit

Permalink
Assert return value of expected_http_error (#1308)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Wiese <matthewwiese@users.noreply.github.com>
  • Loading branch information
toslunar and matthewwiese committed Aug 15, 2023
1 parent a25440c commit ed65a6c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
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)

0 comments on commit ed65a6c

Please sign in to comment.