-
Notifications
You must be signed in to change notification settings - Fork 37
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
fix: ignore test_a_suffix snapshots when running test_a #607
Conversation
src/syrupy/location.py
Outdated
return self.filename == loc.stem or any( | ||
self.filename == parent.name for parent in loc.parents | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is to handle the SingleFileExtension (image + json). Right now it's not strict enough since the parents will traverse all the way up to the root of the file system.
My proposed logic:
return self.filename == loc.stem or any( | |
self.filename == parent.name for parent in loc.parents | |
) | |
return self.filename == loc.stem or self.filename == loc.parent.name |
This does break the ability for an extension to have additional depth in their snapshot directories, but I think that's an okay compromise (my plans for syrupy in v3 are to restrict the API a bit to make internal refactoring easier -- we were a bit overzealous with how "extensible" we made everything).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me 👍 I've made that update and validated it in the tests.
## [2.3.1](v2.3.0...v2.3.1) (2022-07-07) ### Bug Fixes * ignore test_a_suffix snapshots when running test_a ([#607](#607)) ([988a8ab](988a8ab))
🎉 This PR is included in version 2.3.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Woohoo, thank you! |
Description
This fixes #596 by making the filename vs. snapshot location matching stricter: instead of allowing a filename of
test_file
to match if it's a substring of the location (e.g.FOOtest_fileBAR
would match), it now only matches if either of these are true:test_file.ambr
matches, whiletest_file_whatever.ambr
does not).../test_file/foo.bar
matches, but.../test_file.foo/bar
does not, nor.../test_file/subdirectory/foo.bar
)I've added tests for this, as well as expanding the existing ones for #529 to include checking test names that have matching suffices (especially relevant for
tests/integration/test_snapshot_similar_names_file_extension.py
, with the single file snapshots). All three sets of changed tests fail without the change tolocation.py
.Related Issues
Checklist
Additional Comments
Thanks for Syrupy!