test(windows): make test_init_cmd.py Windows-compatible (#643)#724
Merged
test(windows): make test_init_cmd.py Windows-compatible (#643)#724
Conversation
Cluster G of the #643 sweep — 3 fixes in one file, all making the test suite Windows-compatible without touching production: 1) `test_project_install_profile_no_packages_dir` — skipif(win32). The test monkeypatches `sys.executable` to `"/usr/local/bin/python"` and then expects `mm_binary_origin == "system"`. On Windows `Path()` normalizes that string to backslashes, defeating the production `startswith("/usr/local/bin/")` check in `_detect_mm_binary_origin`. The fixture is POSIX-only by construction; rewriting it for Windows would need a Windows-flavored "system Python" path which has no single canonical answer (`C:\Python313\python.exe`? `py.exe`?). 2) `test_origin_system_paths` — skipif(win32). Same root cause: the test iterates over hardcoded POSIX paths (`/usr/bin/python3`, `/opt/homebrew/bin/python3.13`, etc.) and asserts `system` classification. None of these exist on Windows, and the prefix-match logic uses POSIX literals. 3) `_write_md` helper — `newline=""`. The helper is used by `test_collect_seed_scale_counts_md_only_and_sums_bytes` which asserts `total == len("hello world\n") + 100 == 112`. On Windows `Path.write_text` translates `\n` → `\r\n` by default (universal newlines), making the file 1 byte longer and the assertion fail `113 == 112`. Adding `newline=""` disables translation; production `_collect_seed_scale` already reads raw byte counts, so no production change is needed. Mirrors PR #713's bundling pattern (multiple skipif sites in one PR when they share the same POSIX-only rationale) and PR #714's bundling pattern (helper-level fix sweeping the test sites that depend on it). macOS: 262/262 pass. Lint clean. Co-Authored-By: Claude <[email protected]>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
Cluster G of the #643 Windows sweep — 3 fixes in
test_init_cmd.py, all making the test suite Windows-compatible without touching production. Bundled because they share the same axis (test_init_cmd.pyWindows compat) and follow PR #713 / #714's "bundle by mechanism class" pattern.test_project_install_profile_no_packages_dirsys.executable = "/usr/local/bin/python"; on WindowsPath()normalizes that to backslashes, defeating production'sstartswith("/usr/local/bin/")checktest_origin_system_paths/usr/bin/,/opt/homebrew/, etc.); none exist on Windows_write_mdhelpernewline=""onwrite_textPath.write_texttranslates\n→\r\nby default on Windows; the dependent test asserts an exact byte count, failing113 == 112Why skipif (not rewrite for Windows) for #1 and #2
The classifier under test (
_detect_mm_binary_origin) is a heuristic that tags well-known POSIX system Python locations. There is no canonical Windows analog (C:\Python313\python.exe?py.exe?WindowsApps\PythonSoftwareFoundation.Python.3.13...\python.exe?), so a "Windows system paths" rewrite would need a separate design call and is out of scope for this mechanical sweep.Why production stays untouched
_detect_mm_binary_originis correct on POSIX and intentionally permissive on Windows (returnsunknown, which the wizard treats likeuv-tool— see the docstring atinit_cmd.py:230-251)._collect_seed_scalereads raw byte counts viaos.stat— already correct cross-platform.Test plan
uv run pytest packages/memtomem/tests/test_init_cmd.py— 262/262 pass.ruff check+ruff format --checkclean.Out of scope
The remaining 23 Windows failures cluster into A (dirty state, 9 tests), C (claude-projects scope, 2), E (tilde expansion, 1), H (misc, 2). Cluster B (memory_dir prefix, 9) intentionally skipped — parallel work in flight on
fix/647-windows-memory-dir-prefixandfix/720-source-filter-windows.🤖 Generated with Claude Code