Skip to content

fix(tests): make the test suite pass on a default Windows checkout - #3634

Open
MohammedAlkindi wants to merge 2 commits into
openai:mainfrom
MohammedAlkindi:fix/windows-test-checkout
Open

fix(tests): make the test suite pass on a default Windows checkout#3634
MohammedAlkindi wants to merge 2 commits into
openai:mainfrom
MohammedAlkindi:fix/windows-test-checkout

Conversation

@MohammedAlkindi

Copy link
Copy Markdown
  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

On a fresh clone on Windows with stock Git settings, pytest fails 4 tests before any code is touched:

FAILED tests/test_client.py::TestOpenAI::test_proxy_environment_variables
FAILED tests/test_client.py::TestAsyncOpenAI::test_proxy_environment_variables
FAILED tests/test_transform.py::test_base64_file_input[sync]
FAILED tests/test_transform.py::test_base64_file_input[async]
4 failed, 7120 passed, 29 skipped in 71.94s (0:01:11)

Two unrelated mechanisms, one tiny fix each:

  1. test_base64_file_input asserts on the fixture's exact bytes (SGVsbG8sIHdvcmxkIQo=, i.e. "Hello, world!\n"). Git for Windows defaults to core.autocrlf=true, so checkout rewrites tests/sample_file.txt to CRLF and the encoding becomes SGVsbG8sIHdvcmxkIQ0K ("Hello, world!\r\n"). The repo has no .gitattributes, so nothing pins the fixture's bytes — added one marking that single file -text. The committed blob is already LF, so no renormalization is involved; only future checkouts change.

  2. test_proxy_environment_variables (sync and async) sets HTTPS_PROXY first and then deletes the lowercase variants as cleanup. os.environ is case-insensitive on Windows, so monkeypatch.delenv("https_proxy") also removes the HTTPS_PROXY that was just set — the client sees no proxy in the environment and the mounts assertion fails with len(mounts) == 0. Reordered: cleanup first, then setenv. On POSIX the two orders are equivalent (the lowercase names are genuinely distinct variables there), so nothing changes for existing platforms.

After the two changes, same machine:

tests/test_client.py::TestOpenAI::test_proxy_environment_variables PASSED
tests/test_client.py::TestAsyncOpenAI::test_proxy_environment_variables PASSED
tests/test_transform.py::test_base64_file_input[sync] PASSED
tests/test_transform.py::test_base64_file_input[async] PASSED

and both files in full: 254 passed, 2 skipped (the skips are pre-existing). I re-ran the affected files, not the whole 7k-test suite, for the "after" numbers.

Additional context & links

  • Neither edited file carries the Castiron generated-file banner, and .gitattributes is new, so nothing generated was touched. If these tests are actually maintained in your generator templates, the two changes are deliberately minimal so they should be easy to port there instead.
  • Environment: Windows 11, git 2.53.0.windows.2 (default core.autocrlf=true), Python 3.12.10, dependencies from requirements-dev.lock, mock server started per scripts/mock (@stdy/cli@0.22.1).

tests/sample_file.txt is asserted on byte-for-byte by the base64 transform
tests, but with core.autocrlf (the Git for Windows default) a fresh clone
rewrites it to CRLF and both test_base64_file_input variants fail. Mark the
fixture -text so every platform checks out the exact committed bytes.
test_proxy_environment_variables set HTTPS_PROXY first and then deleted
the lowercase variants as cleanup. os.environ is case-insensitive on
Windows, so delenv("https_proxy") also removed the HTTPS_PROXY that was
just set, the client saw no proxy in the environment, and the mounts
assertion failed. Do the cleanup first and set the variable afterwards.
@MohammedAlkindi
MohammedAlkindi requested a review from a team as a code owner August 16, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant