From 3bf32ced6b8581a43d149260cfb7ed15524fb566 Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Singh Date: Sat, 15 Aug 2026 15:08:48 +0530 Subject: [PATCH] test: make suite deterministic on Windows --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ tests/test_client.py | 10 ++++++---- tests/test_transform.py | 3 ++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 467456a1..3403190a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,3 +74,26 @@ jobs: - name: Run tests run: ./scripts/test + + windows-test: + timeout-minutes: 15 + name: test (Windows) + runs-on: windows-latest + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Install uv + uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2 + with: + version: '0.10.2' + + - name: Install dependencies + run: uv sync --python 3.12 --all-extras + + - name: Start mock server + run: ./scripts/mock --daemon + shell: bash + + - name: Run tests + run: uv run --python 3.12 pytest diff --git a/tests/test_client.py b/tests/test_client.py index 95ae8e03..cd4261db 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -979,8 +979,6 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: assert response.http_request.headers.get("x-stainless-retry-count") == "42" def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: - # Test that the proxy environment variables are set correctly - monkeypatch.setenv("HTTPS_PROXY", "https://example.org") # Delete in case our environment has any proxy env vars set monkeypatch.delenv("HTTP_PROXY", raising=False) monkeypatch.delenv("ALL_PROXY", raising=False) @@ -989,6 +987,9 @@ def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> N monkeypatch.delenv("https_proxy", raising=False) monkeypatch.delenv("all_proxy", raising=False) monkeypatch.delenv("no_proxy", raising=False) + # Set this after deleting both casing variants. Windows environment + # variable names are case-insensitive. + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") client = DefaultHttpxClient() @@ -1919,8 +1920,6 @@ async def test_get_platform(self) -> None: assert isinstance(platform, (str, OtherPlatform)) async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: - # Test that the proxy environment variables are set correctly - monkeypatch.setenv("HTTPS_PROXY", "https://example.org") # Delete in case our environment has any proxy env vars set monkeypatch.delenv("HTTP_PROXY", raising=False) monkeypatch.delenv("ALL_PROXY", raising=False) @@ -1929,6 +1928,9 @@ async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch monkeypatch.delenv("https_proxy", raising=False) monkeypatch.delenv("all_proxy", raising=False) monkeypatch.delenv("no_proxy", raising=False) + # Set this after deleting both casing variants. Windows environment + # variable names are case-insensitive. + monkeypatch.setenv("HTTPS_PROXY", "https://example.org") client = DefaultAsyncHttpxClient() diff --git a/tests/test_transform.py b/tests/test_transform.py index c31b1f40..fb8c8c3f 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -1,6 +1,7 @@ from __future__ import annotations import io +import base64 import pathlib from typing import Any, Dict, List, Union, TypeVar, Iterable, Optional, cast from datetime import date, datetime @@ -422,7 +423,7 @@ async def test_base64_file_input(use_async: bool) -> None: # pathlib.Path is automatically converted to base64 assert await transform({"foo": SAMPLE_FILE_PATH}, TypedDictBase64Input, use_async) == { - "foo": "SGVsbG8sIHdvcmxkIQo=" + "foo": base64.b64encode(SAMPLE_FILE_PATH.read_bytes()).decode("ascii") } # type: ignore[comparison-overlap] # io instances are automatically converted to base64