Skip to content

Commit 6f61f85

Browse files
committed
Test callable environments formatting
If the environment has an escaped variable (so, a string), the server should start without failing to format it.
1 parent 3eece1d commit 6f61f85

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

tests/resources/jupyter_server_config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def cats_only(response, path):
4242
response.code = 403
4343
response.body = b"dogs not allowed"
4444

45+
def my_env():
46+
return {
47+
"MYVAR": "String with escaped {{var}}"
48+
}
4549

4650
c.ServerProxy.servers = {
4751
"python-http": {
@@ -65,6 +69,10 @@ def cats_only(response, path):
6569
"command": [sys.executable, "./tests/resources/httpinfo.py", "--port={port}"],
6670
"mappath": mappathf,
6771
},
72+
"python-http-callable-env": {
73+
"command": [sys.executable, "./tests/resources/httpinfo.py", "--port={port}"],
74+
"environment": my_env,
75+
},
6876
"python-websocket": {
6977
"command": [sys.executable, "./tests/resources/websocket.py", "--port={port}"],
7078
"request_headers_override": {

tests/test_proxies.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,3 +408,9 @@ def test_bad_server_proxy_url(
408408
if status >= 400:
409409
# request should not have been proxied
410410
assert "X-ProxyContextPath" not in r.headers
411+
412+
413+
def test_callable_environment_formatting(a_server_port_and_token: Tuple[int, str]) -> None:
414+
PORT, TOKEN = a_server_port_and_token
415+
r = request_get(PORT, "/python-http-callable-env/test", TOKEN)
416+
assert r.code == 200

0 commit comments

Comments
 (0)