Skip to content

test: compare the encoded path with str(Path(...)) - #432

Open
Luckyou-d wants to merge 1 commit into
langgenius:mainfrom
Luckyou-d:test/encoder-path-is-platform-specific
Open

Luckyou-d wants to merge 1 commit into
langgenius:mainfrom
Luckyou-d:test/encoder-path-is-platform-specific

Conversation

@Luckyou-d

Copy link
Copy Markdown
Contributor

Important

  1. Make sure you have read our contribution guidelines
  2. Search existing issues and pull requests to confirm this change is not a duplicate
  3. Open or identify the issue this pull request resolves or advances
  4. Use a Conventional Commits title for this pull request, and mark breaking changes with !
  5. Remember that the pull request title will become the squash merge commit message
  6. If CLA Assistant prompts you, sign CLA.md in the pull request conversation

Related Issue

Closes #431

Summary

jsonable_encoder maps Path to str (src/graphon/model_runtime/utils/encoders.py:86), so the separator in the answer is the platform's. The test asserted a POSIX literal, so it failed on Windows for a reason that has nothing to do with the encoder:

Windows: assert '\example\test' == '/example/test'

The test now compares against str(Path("/example/test")), which states the mapping without pinning it to one system, and keeps the PurePath case alongside it.

Deliberately test-side only: making the encoder emit as_posix() for every Path would change what a Windows user's paths look like in the JSON the API returns. That is a product decision - I am happy to make it a separate change if stable output across platforms is what you want; it was not something I wanted to slip into a test fix.

Verification

  • pytest tests/model_runtime/test_encoders.py -> 17 passed; on main the path case fails with the assertion above.
  • ruff check, ruff format --check clean, and ty check reports only the two diagnostics that main already has in tests/variables/test_factory.py.
  • Full suite on this branch still shows the 8 test_repository_docs failures that test: format repository-docs messages with forward slashes #430 fixes; they are unrelated to this file and are red on main here.

Checklist

  • This pull request links the issue it resolves or advances
  • This pull request title follows Conventional Commits, and any breaking change is marked with !
  • If CLA Assistant prompted me, I signed CLA.md in the pull request conversation

`jsonable_encoder` maps `Path` to `str`, so the separator is the platform's; the
test asserted a POSIX literal and was red on Windows for a reason unrelated to
the encoder. Comparing against `str(Path(...))` states what the mapping does
without pinning it to one system.

This branch has not been deployed

No deployments
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.

The encoder path test asserts a POSIX rendering of Path, so it fails on Windows

1 participant