Skip to content

Commit b5ef979

Browse files
committed
CI: add windows to test platforms
We run test on windows for a single python release. This is to check platform compatibility.
1 parent 7bf1966 commit b5ef979

5 files changed

Lines changed: 36 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,18 @@ jobs:
3535
make mypy
3636
3737
test:
38-
name: Test with python ${{ matrix.python-version }}
39-
runs-on: ubuntu-latest
38+
name: Test with python ${{ matrix.python-version }} / ${{ matrix.os-version }}
4039
strategy:
4140
matrix:
4241
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
42+
os-version: ["ubuntu-latest", "windows-latest"]
43+
exclude:
44+
- os-version: windows-latest
45+
include:
46+
- os-version: windows-latest
47+
python-version: 3.12
48+
49+
runs-on: ${{ matrix.os-version }}
4350

4451
steps:
4552

@@ -54,11 +61,24 @@ jobs:
5461
poetry-version: ${{ env.POETRY_VERSION }}
5562

5663
- name: Test
64+
if: runner.os == 'Linux'
5765
run: |
5866
make cov
5967
68+
- name: Test
69+
if: runner.os == 'Windows'
70+
shell: bash
71+
env:
72+
PYTEST_HTTPSERVER_HOST: '127.0.0.1'
73+
run: |
74+
set -e
75+
poetry run pytest tests -s -vv --release
76+
poetry run pytest tests -s -vv --ssl
77+
78+
6079
- name: Codecov upload
6180
uses: codecov/codecov-action@v4
81+
if: runner.os == 'Linux'
6282
with:
6383
token: ${{ secrets.CODECOV_TOKEN }}
6484

tests/test_blocking_httpserver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,4 @@ def test_raises_assertion_error_when_request_was_not_responded(httpserver: Block
122122

123123

124124
def test_repr(httpserver: BlockingHTTPServer):
125-
assert repr(httpserver) == f"<BlockingHTTPServer host=localhost port={httpserver.port}>"
125+
assert repr(httpserver) == f"<BlockingHTTPServer host={httpserver.host} port={httpserver.port}>"

tests/test_log_querying.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_verify_assert_msg(httpserver: HTTPServer):
4747
"Path: /foo",
4848
"Method: GET",
4949
"Body: b''",
50-
f"Headers: Host: localhost:{httpserver.port}",
50+
f"Headers: Host: {httpserver.host}:{httpserver.port}",
5151
"User-Agent: requests",
5252
"Accept-Encoding: gzip, deflate",
5353
"Accept: */*",

tests/test_mixed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@ def test_all_ordered_missing(httpserver: HTTPServer):
8585

8686

8787
def test_repr(httpserver: HTTPServer):
88-
assert repr(httpserver) == f"<HTTPServer host=localhost port={httpserver.port}>"
88+
assert repr(httpserver) == f"<HTTPServer host={httpserver.host} port={httpserver.port}>"

tests/test_ssl.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import pytest
66
import requests
77

8+
from pytest_httpserver import HTTPServer
9+
810
pytestmark = pytest.mark.ssl
911

1012
test_dir = os.path.dirname(os.path.realpath(__file__))
@@ -24,18 +26,23 @@ def httpserver_ssl_context():
2426
return ssl.SSLContext(protocol)
2527

2628

27-
def test_ssl(httpserver):
29+
def test_ssl(httpserver: HTTPServer):
2830
server_crt = pjoin(assets_dir, "server.crt")
2931
server_key = pjoin(assets_dir, "server.key")
3032
root_ca = pjoin(assets_dir, "rootCA.crt")
31-
context = httpserver.ssl_context
3233

3334
assert (
34-
context is not None
35+
httpserver.ssl_context is not None
3536
), "SSLContext not set. The session was probably started with a test that did not define an SSLContext."
3637

3738
httpserver.ssl_context.load_cert_chain(server_crt, server_key)
3839
httpserver.expect_request("/foobar").respond_with_json({"foo": "bar"})
3940

4041
assert httpserver.is_running()
41-
assert requests.get(httpserver.url_for("/foobar"), verify=root_ca).json() == {"foo": "bar"}
42+
43+
assert httpserver.url_for("/").startswith("https://")
44+
45+
# ensure we are using "localhost" and not "127.0.0.1" to pass cert verification
46+
url = f"https://localhost:{httpserver.port}/foobar"
47+
48+
assert requests.get(url, verify=root_ca).json() == {"foo": "bar"}

0 commit comments

Comments
 (0)