Skip to content

Commit 1d06382

Browse files
authored
Merge pull request #392 from manics/windows
Test Windows
2 parents 84f06f4 + 2074b68 commit 1d06382

File tree

6 files changed

+71
-47
lines changed

6 files changed

+71
-47
lines changed

.github/workflows/test.yaml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,24 @@ on:
2525

2626
jobs:
2727
test:
28-
# NOTE: The worker environment running this job needs firefox and
29-
# geckowebdriver available. Before upgrading to ubuntu-24.04 in the
30-
# future, check and see its available in a location like this:
31-
# https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#browsers-and-drivers
32-
#
33-
runs-on: ubuntu-22.04
34-
28+
timeout-minutes: 30
3529
strategy:
3630
fail-fast: false
3731
matrix:
3832
python-version: ["3.8", "3.11"]
3933
jupyter_server-version: ["1", "2"]
4034
jupyterlab-version: ["3"]
35+
os: [ubuntu-22.04]
36+
include:
37+
- python-version: "3.11"
38+
jupyter_server-version: "2"
39+
jupyterlab-version: "3"
40+
os: windows-2022
41+
42+
runs-on: ${{ matrix.os }}
43+
defaults:
44+
run:
45+
shell: bash
4146

4247
steps:
4348
- uses: actions/checkout@v3
@@ -76,7 +81,7 @@ jobs:
7681
7782
- name: Run tests
7883
run: |
79-
pytest -k "not acceptance"
84+
pytest -k "not acceptance" -vv
8085
8186
- name: Upload pytest and coverage reports
8287
if: always()

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ classifiers = [
3535
"Framework :: Jupyter :: JupyterLab :: Extensions",
3636
"License :: OSI Approved :: BSD License",
3737
"Operating System :: MacOS :: MacOS X",
38+
"Operating System :: Microsoft :: Windows",
3839
"Operating System :: POSIX :: Linux",
3940
"Programming Language :: Python",
4041
"Programming Language :: Python :: 3",
@@ -47,7 +48,7 @@ dependencies = [
4748
"aiohttp",
4849
"importlib_metadata >=4.8.3 ; python_version<\"3.10\"",
4950
"jupyter-server >=1.0",
50-
"simpervisor >=0.4",
51+
"simpervisor >=1.0",
5152
]
5253

5354
[project.optional-dependencies]
@@ -86,6 +87,10 @@ exclude = [
8687
"jupyter_server_proxy/labextension" = "share/jupyter/labextensions/@jupyterhub/jupyter-server-proxy"
8788
"jupyter_server_proxy/static" = "share/jupyter/nbextensions/jupyter_server_proxy"
8889

90+
[tool.hatch.metadata]
91+
# Set to true to allow testing of git+https://github.com/user/repo@sha dependencies
92+
allow-direct-references = false
93+
8994
[tool.hatch.metadata.hooks.nodejs]
9095
path = "labextension/package.json"
9196
fields = ["description", "authors", "urls"]

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/httpinfo.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55
import argparse
66
import socket
7+
import sys
78
from http.server import BaseHTTPRequestHandler, HTTPServer
89
from pathlib import Path
910

@@ -28,8 +29,10 @@ def address_string(self):
2829
return super().address_string()
2930

3031

31-
class HTTPUnixServer(HTTPServer):
32-
address_family = socket.AF_UNIX
32+
if sys.platform != "win32":
33+
34+
class HTTPUnixServer(HTTPServer):
35+
address_family = socket.AF_UNIX
3336

3437

3538
if __name__ == "__main__":

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},

tests/test_proxies.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import gzip
33
import json
4+
import sys
45
from http.client import HTTPConnection
56
from io import BytesIO
67
from typing import Tuple
@@ -23,15 +24,30 @@ def request_get(port, path, token, host=LOCALHOST):
2324
return h.getresponse()
2425

2526

26-
@pytest.mark.parametrize(
27-
"server_process_path",
28-
[
29-
"/python-http/",
27+
PARAMETERIZED_SERVER_PROCESS_PATHS = [
28+
"/python-http/",
29+
pytest.param(
3030
"/python-unix-socket-true/",
31+
marks=pytest.mark.skipif(
32+
sys.platform == "win32", reason="Unix socket not supported on Windows"
33+
),
34+
),
35+
pytest.param(
3136
"/python-unix-socket-file/",
37+
marks=pytest.mark.skipif(
38+
sys.platform == "win32", reason="Unix socket not supported on Windows"
39+
),
40+
),
41+
pytest.param(
3242
"/python-unix-socket-file-no-command/",
33-
],
34-
)
43+
marks=pytest.mark.skipif(
44+
sys.platform == "win32", reason="Unix socket not supported on Windows"
45+
),
46+
),
47+
]
48+
49+
50+
@pytest.mark.parametrize("server_process_path", PARAMETERIZED_SERVER_PROCESS_PATHS)
3551
def test_server_proxy_minimal_proxy_path_encoding(
3652
server_process_path: str, a_server_port_and_token: Tuple[int, str]
3753
) -> None:
@@ -50,15 +66,7 @@ def test_server_proxy_minimal_proxy_path_encoding(
5066
assert f"GET /{special_path}&token=" in s
5167

5268

53-
@pytest.mark.parametrize(
54-
"server_process_path",
55-
[
56-
"/python-http/",
57-
"/python-unix-socket-true/",
58-
"/python-unix-socket-file/",
59-
"/python-unix-socket-file-no-command/",
60-
],
61-
)
69+
@pytest.mark.parametrize("server_process_path", PARAMETERIZED_SERVER_PROCESS_PATHS)
6270
def test_server_proxy_hash_sign_encoding(
6371
server_process_path: str, a_server_port_and_token: Tuple[int, str]
6472
) -> None:

0 commit comments

Comments
 (0)