-
-
Notifications
You must be signed in to change notification settings - Fork 134
Unify handling of file & inline snapshots (compat) #528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mitsuhiko
merged 12 commits into
mitsuhiko:master
from
max-sixty:unify-file-inline-compat
Aug 31, 2024
Merged
Unify handling of file & inline snapshots (compat) #528
mitsuhiko
merged 12 commits into
mitsuhiko:master
from
max-sixty:unify-file-inline-compat
Aug 31, 2024
Conversation
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
This is the code for mitsuhiko#456 (comment), as mentioned in mitsuhiko#466. There's a very small change in yaml inline snapshots — shown here in the tests. In return, it makes the macros simpler & more maintainable.
0a479a4 to
3e6bdee
Compare
Owner
|
One thing that is a bit weird I guess is that the leading |
max-sixty
added a commit
that referenced
this pull request
Sep 10, 2025
This is an example of what I've been suggesting at #506 (+ some linked issues): - ~Stacked on #528 so that would need to merge first~ - Enforces the correct number of newlines at the start of snapshots. The start is easier because we don't need to worry about editor issues in trailing newlines (and don't need to worry about how `Lines` deals ambiguously with trailing new lines) - Works for both inline & file snapshots - Adds a `matches_legacy` method on snapshot contents — this encapsulates the older formats we still support and warns about them ~It's not ready to merge yet, because we don't seem to actually support `--force-update-snapshots` on inline values, which is somewhat required. But I'm publishing for feedback & to put some weight on #528 in case we don't want to pursue.~ --------- Co-authored-by: Claude <no-reply@anthropic.com>
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.
This is a version of #468 that doesn't break compatibility — the change in snapshot (removing the leading
---in inline snapshots) is optional, and snapshots still pass if they have it. Otherwise it has the same benefits of #468(There is a tiny corner case that if a snapshot is intended to test whether there's a leading
---, we could get a false match, but this is a very small possibility — much much smaller than removing the line endings we've done)As part of that, this adds
as_str_exact&matches_fullymethods toSnapshotContents, which allows us to unify our normalization of snapshots contents, and allow detecting snapshots that pass but don't completely match; for example if we want to restore checking for line endings.