Skip to content

test: make three fixtures portable so they test the code, not the host platform - #68

Open
Hotragn wants to merge 1 commit into
AlmanacCode:mainfrom
Hotragn:fix/portable-test-fixtures
Open

test: make three fixtures portable so they test the code, not the host platform#68
Hotragn wants to merge 1 commit into
AlmanacCode:mainfrom
Hotragn:fix/portable-test-fixtures

Conversation

@Hotragn

@Hotragn Hotragn commented Aug 19, 2026

Copy link
Copy Markdown

Summary

Five Windows test failures are caused by how the fixtures build their input, not by the code under test. The source is already correct in all three cases. This makes the fixtures portable so they test the code rather than the host platform.

Windows goes from 13 failed / 550 passed to 8 failed / 555 passed. No behaviour change on macOS or Linux — every edit changes only how a fixture serializes its own input.

Why

1. test_tagging.py — 3 failures. Five page fixtures write content with write_text, which translates \n to os.linesep, then assert byte-exact round-tripping with read_bytes(). On Windows the intended \r\n lands on disk as \r\r\n, which is not a valid frontmatter fence — so the page looks like it has no frontmatter, a second block gets prepended, and the original is absorbed into the body:

'---\ntopics:\n- auth\n- sessions\n---\n---\r\r\ntitle: Auth Flow\r\r\n...'
 ^^^^^^^^^^^ new block                 ^^^^^^^^^^ original, now body text

Worth stating plainly: rewrite_page_topics is not at fault. It reads bytes, detects the line ending, and preserves it — I checked before assuming a source bug. newline="" simply writes what the test meant to write.

2. test_transcript_discovery.py — 1 failure. The Claude fixture hand-builds JSONL with an f-string:

f'{{"sessionId":"claude-1","cwd":"{repo}"}}\n'

On Windows repo interpolates as C:\Users\..., so the JSON contains invalid escapes (\U, \A), the line fails to parse, and discover() returns 0 candidates.

Its Codex sibling in the same file already uses json.dumps and passes on Windows for exactly that reason. This just adopts the pattern already established two functions up; json was already imported.

3. test_build_workflow.py — 1 failure. The expected value mixes separators and ignores that the prompt is JSON-encoded:

assert f'"manual_root": "{repo}/almanac/manual"' in adapter.requests[0].prompt

On Windows repo renders with backslashes, then /almanac/manual is appended with a forward slash, while the prompt contains the JSON-escaped native path. Building the expected value with json.dumps and a pathlib join compares like with like.

Verification

# Windows 11, Python 3.13 (uv-managed), uv 0.12.0
uv run pytest tests/test_tagging.py tests/test_transcript_discovery.py \
              tests/test_build_workflow.py -q
# 21 passed

uv run pytest -q          # 8 failed, 555 passed, 1 skipped
# baseline on main:         13 failed, 550 passed, 1 skipped

uv run ruff check .       # All checks passed!
git diff --check          # clean
uv build --out-dir dist   # ok

Also confirmed green on Linux semantics by inspection: newline="" is a no-op where os.linesep is already \n, and json.dumps of a POSIX path is byte-identical to the previous f-string output.

Docs and wiki

  • Not applicable — test fixtures only.

Notes for reviewers


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

…t platform

Five tests fail on Windows because of how their fixtures build input, not because
of the code under test. In each case the source is already correct.

1. `test_tagging.py` (3 failures). Five page fixtures write content through
   `write_text`, which translates "\n" to os.linesep, then assert byte-exact
   round-tripping via `read_bytes()`. On Windows the intended "\r\n" lands as
   "\r\r\n", which is not a valid frontmatter fence, so the page appears to have
   no frontmatter, a second block is prepended and the original is absorbed into
   the body. Passing `newline=""` writes what the test actually wrote.
   `rewrite_page_topics` is not at fault: it reads bytes, detects the ending and
   preserves it.

2. `test_transcript_discovery.py` (1 failure). The Claude fixture hand-builds
   JSONL with an f-string, so a Windows path embeds invalid escapes
   ("cwd":"C:\Users\...") and the line fails to parse, yielding 0 candidates.
   Its Codex sibling in the same file already uses `json.dumps` and passes on
   Windows for exactly that reason, so this just adopts the established pattern.
   `json` was already imported.

3. `test_build_workflow.py` (1 failure). The expected value mixes separators by
   interpolating a native path and appending "/almanac/manual", and does not
   account for the prompt being JSON-encoded. Building it with `json.dumps` and
   pathlib joins compares like with like.

Windows goes from 13 failed / 550 passed to 8 failed / 555 passed. The remaining
8 are the 5 macOS-only `launchd` tests plus 3 covered by AlmanacCode#64 and AlmanacCode#65; with those
merged, the only Windows failures left are the `launchd` ones, which is the point
at which a Windows CI job could be added and mean something. No behaviour change
on macOS or Linux: every edit changes only how a fixture serializes its input.
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