#91 notes that tests/test_cli.py only checks artifact reuse when a fingerprint matches. There were no direct tests for the hashing contract: path+content stability, ignore lists, mtime independence, missing/empty roots, and single-file hashing.
Implementation
New tests/project/test_fingerprint.py.
Uses small tmp_path fixtures and compares hashes to each other rather than hard-coded digests.
Covers ignored dirs (build, __pycache__, .git) and suffixes (.pyc, .DS_Store).
Uses os.utime() to confirm mtime-only changes do not affect the digest.
Testing
This environment has Python 3.12; the project requires 3.13 (class Route[P: RouteParams = ...]), so uv run pytest / ./scripts/check.sh could not be run here.
The six cases were executed against hash_tree by loading src/pythonnative/project/fingerprint.py with a stub config module on Python 3.12. All assertions passed:
identical trees under different roots / creation order
byte change and rename change the hash
mtime-only change does not
ignored paths do not; a new source file does
missing root and empty directory share the empty digest
hashing a single file is path-root independent for the same basename+bytes
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
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
Adds direct tests for hash_tree() so native fingerprint hashing is covered without going through the CLI or a native build.
Closes #91.
Motivation
#91 notes that tests/test_cli.py only checks artifact reuse when a fingerprint matches. There were no direct tests for the hashing contract: path+content stability, ignore lists, mtime independence, missing/empty roots, and single-file hashing.
Implementation
Testing
This environment has Python 3.12; the project requires 3.13 (class Route[P: RouteParams = ...]), so uv run pytest / ./scripts/check.sh could not be run here.
The six cases were executed against hash_tree by loading src/pythonnative/project/fingerprint.py with a stub config module on Python 3.12. All assertions passed: