-
Notifications
You must be signed in to change notification settings - Fork 34
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
Unused snapshots when running on filename (test_a.py) that's the prefix of another (test_abc.py) #596
Comments
Odd. This sounds like a regression of an old issue. We even have explicit tests around the prefix case. I'll have to dig into this. |
You can see the existing coverage we have for this here: https://github.com/tophat/syrupy/blob/master/tests/integration/test_snapshot_similar_names_default.py and related issue: #529 |
Ah yeah, I can see the similarities 👍 It looks like that one is more about the names of the test functions themselves whereas this one is about the file names? |
The bit of logic responsible for all this is here: https://github.com/tophat/syrupy/blob/f189e65a77923090154c93bfe9883e5854dd84b1/src/syrupy/report.py#L183. I do have a feeling this was a relatively recent regression but will have to dig into it some more when I have some time later this week. If you want to try take a stab at it yourself, feel free to do so. I'm available to answer questions. |
Thanks for the tip, that was helpful. I've made an attempt in #607. |
🎉 This issue has been resolved in version 2.3.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Describe the bug
I have a project that has filenames where the non-
.py
part happens to be a prefix of another (e.g.test_a.py
vs.test_abc.py
). When runningtest_a.py
in isolation, syrupy picks up the snapshots fromtest_abc.py
and either warns/errors about them or deletes them (depending on if--snapshot-update
) is specified.(Thanks for syrupy!)
To reproduce
With the above code, if I run
pytest test_a.py
, the snapshot fromtest_abc.py
is flagged as unused:Fully packaged:
Expected behavior
When running pytest against a single/subset of files, snapshots from other files shouldn't be considered unused.
Screenshots
Environment (please complete the following information):
Additional context
N/A
The text was updated successfully, but these errors were encountered: