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

pytest_plugin: allow user specified headers in jp_ws_fetch #580

Merged
merged 2 commits into from
Sep 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions jupyter_server/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,11 @@ async def my_test(jp_fetch):
...
"""

def client_fetch(*parts, headers={}, params={}, **kwargs):
def client_fetch(*parts, headers=None, params=None, **kwargs):
if not headers:
headers = {}
if not params:
params = {}
# Handle URL strings
path_url = url_escape(url_path_join(*parts), plus=False)
base_path_url = url_path_join(jp_base_url, path_url)
Expand Down Expand Up @@ -358,7 +362,11 @@ async def my_test(jp_fetch, jp_ws_fetch):
...
"""

def client_fetch(*parts, headers={}, params={}, **kwargs):
def client_fetch(*parts, headers=None, params=None, **kwargs):
if not headers:
headers = {}
if not params:
params = {}
# Handle URL strings
path_url = url_escape(url_path_join(*parts), plus=False)
base_path_url = url_path_join(jp_base_url, path_url)
Expand All @@ -368,7 +376,7 @@ def client_fetch(*parts, headers={}, params={}, **kwargs):
# Add auth keys to header
headers.update(jp_auth_header)
# Make request.
req = tornado.httpclient.HTTPRequest(url, headers=jp_auth_header, connect_timeout=120)
req = tornado.httpclient.HTTPRequest(url, headers=headers, connect_timeout=120)
return tornado.websocket.websocket_connect(req)

return client_fetch
Expand Down