Skip to content

Commit 40726e6

Browse files
committed
Fix url error handling in conftest, don't hardcode python3
1 parent fb925a7 commit 40726e6

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

tests/conftest.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,19 @@ def a_server(
8181
try:
8282
urlopen(canary_url)
8383
break
84-
except URLError as err:
85-
if "Connection refused" in str(err):
84+
except URLError:
85+
if not retries:
8686
print(
87-
f"{a_server_cmd} not ready, will try again in 0.5s [{retries} retries]",
87+
f"{a_server_cmd} not ready, aborting",
8888
flush=True,
8989
)
90-
time.sleep(0.5)
91-
retries -= 1
92-
continue
93-
raise err
90+
raise
91+
print(
92+
f"{a_server_cmd} not ready, will try again in 0.5s [{retries} retries]",
93+
flush=True,
94+
)
95+
time.sleep(0.5)
96+
retries -= 1
9497

9598
print(f"{a_server_cmd} is ready...", flush=True)
9699

tests/resources/jupyter_server_config.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,43 +45,43 @@ def cats_only(response, path):
4545

4646
c.ServerProxy.servers = {
4747
"python-http": {
48-
"command": ["python3", "./tests/resources/httpinfo.py", "--port={port}"],
48+
"command": [sys.executable, "./tests/resources/httpinfo.py", "--port={port}"],
4949
},
5050
"python-http-abs": {
51-
"command": ["python3", "./tests/resources/httpinfo.py", "--port={port}"],
51+
"command": [sys.executable, "./tests/resources/httpinfo.py", "--port={port}"],
5252
"absolute_url": True,
5353
},
5454
"python-http-port54321": {
55-
"command": ["python3", "./tests/resources/httpinfo.py", "--port={port}"],
55+
"command": [sys.executable, "./tests/resources/httpinfo.py", "--port={port}"],
5656
"port": 54321,
5757
},
5858
"python-http-mappath": {
59-
"command": ["python3", "./tests/resources/httpinfo.py", "--port={port}"],
59+
"command": [sys.executable, "./tests/resources/httpinfo.py", "--port={port}"],
6060
"mappath": {
6161
"/": "/index.html",
6262
},
6363
},
6464
"python-http-mappathf": {
65-
"command": ["python3", "./tests/resources/httpinfo.py", "--port={port}"],
65+
"command": [sys.executable, "./tests/resources/httpinfo.py", "--port={port}"],
6666
"mappath": mappathf,
6767
},
6868
"python-websocket": {
69-
"command": ["python3", "./tests/resources/websocket.py", "--port={port}"],
69+
"command": [sys.executable, "./tests/resources/websocket.py", "--port={port}"],
7070
"request_headers_override": {
7171
"X-Custom-Header": "pytest-23456",
7272
},
7373
},
7474
"python-unix-socket-true": {
7575
"command": [
76-
"python3",
76+
sys.executable,
7777
"./tests/resources/httpinfo.py",
7878
"--unix-socket={unix_socket}",
7979
],
8080
"unix_socket": True,
8181
},
8282
"python-unix-socket-file": {
8383
"command": [
84-
"python3",
84+
sys.executable,
8585
"./tests/resources/httpinfo.py",
8686
"--unix-socket={unix_socket}",
8787
],
@@ -93,29 +93,29 @@ def cats_only(response, path):
9393
"unix_socket": "/tmp/jupyter-server-proxy-test-socket",
9494
},
9595
"python-request-headers": {
96-
"command": ["python3", "./tests/resources/httpinfo.py", "--port={port}"],
96+
"command": [sys.executable, "./tests/resources/httpinfo.py", "--port={port}"],
9797
"request_headers_override": {
9898
"X-Custom-Header": "pytest-23456",
9999
},
100100
},
101101
"python-gzipserver": {
102-
"command": ["python3", "./tests/resources/gzipserver.py", "{port}"],
102+
"command": [sys.executable, "./tests/resources/gzipserver.py", "{port}"],
103103
},
104104
"python-http-rewrite-response": {
105-
"command": ["python3", "./tests/resources/httpinfo.py", "--port={port}"],
105+
"command": [sys.executable, "./tests/resources/httpinfo.py", "--port={port}"],
106106
"rewrite_response": translate_ciao,
107107
"port": 54323,
108108
},
109109
"python-chained-rewrite-response": {
110-
"command": ["python3", "./tests/resources/httpinfo.py", "--port={port}"],
110+
"command": [sys.executable, "./tests/resources/httpinfo.py", "--port={port}"],
111111
"rewrite_response": [translate_ciao, hello_to_foo],
112112
},
113113
"python-cats-only-rewrite-response": {
114-
"command": ["python3", "./tests/resources/httpinfo.py", "--port={port}"],
114+
"command": [sys.executable, "./tests/resources/httpinfo.py", "--port={port}"],
115115
"rewrite_response": [dog_to_cat, cats_only],
116116
},
117117
"python-dogs-only-rewrite-response": {
118-
"command": ["python3", "./tests/resources/httpinfo.py", "--port={port}"],
118+
"command": [sys.executable, "./tests/resources/httpinfo.py", "--port={port}"],
119119
"rewrite_response": [cats_only, dog_to_cat],
120120
},
121121
"python-proxyto54321-no-command": {"port": 54321},

0 commit comments

Comments
 (0)