fix(tests): make the test suite pass on a default Windows checkout - #3634
Open
MohammedAlkindi wants to merge 2 commits into
Open
fix(tests): make the test suite pass on a default Windows checkout#3634MohammedAlkindi wants to merge 2 commits into
MohammedAlkindi wants to merge 2 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes being requested
On a fresh clone on Windows with stock Git settings,
pytestfails 4 tests before any code is touched:Two unrelated mechanisms, one tiny fix each:
test_base64_file_inputasserts on the fixture's exact bytes (SGVsbG8sIHdvcmxkIQo=, i.e."Hello, world!\n"). Git for Windows defaults tocore.autocrlf=true, so checkout rewritestests/sample_file.txtto CRLF and the encoding becomesSGVsbG8sIHdvcmxkIQ0K("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.test_proxy_environment_variables(sync and async) setsHTTPS_PROXYfirst and then deletes the lowercase variants as cleanup.os.environis case-insensitive on Windows, somonkeypatch.delenv("https_proxy")also removes theHTTPS_PROXYthat was just set — the client sees no proxy in the environment and the mounts assertion fails withlen(mounts) == 0. Reordered: cleanup first, thensetenv. 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:
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
.gitattributesis 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.core.autocrlf=true), Python 3.12.10, dependencies fromrequirements-dev.lock, mock server started perscripts/mock(@stdy/cli@0.22.1).