-
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: support call syntax for snapshot fixture overriding #160
Conversation
Codecov Report
@@ Coverage Diff @@
## master #160 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 16 16
Lines 841 859 +18
=========================================
+ Hits 841 859 +18 |
@noahnu using |
tests/test_extension_image.py
Outdated
) | ||
assert snapshot_svg == actual_svg | ||
assert actual_svg == snapshot(extension_class=SVGImageSnapshotExtension) | ||
assert actual_svg == snapshot # last extension class specified is used |
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 feel like that behaviour can be confusing. Perhaps it should function similar to snapshot.use_extension, where it effectively clones the snapshot instance
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.
If it clones it then it'll lose the context of assertion index, leading to duplicates
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.
we can clone assertion index. I find it strange that calling snapshot
at the beginning of a test case can affect snapshot assertions towards the end of the test case. Strange side-effects
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.
@noahnu so your preferred behaviour would be having this line use the default snapshot extension class? It does make it more "pure" but then requires a lot of cloning of state values. Since the snapshot fixture is bound to the test case function the limit of the side effects would only be in specific test, I don't think that's too confusing and it would allow for doing stuff like #161 without a lot of copying.
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.
@noahnu also I don't think we could track with cloning assertion index if each individual assertion in the test case is a new instance
) | ||
assert snapshot_svg == actual_svg | ||
assert actual_svg == snapshot(extension_class=SVGImageSnapshotExtension) | ||
assert actual_svg == snapshot # uses initial extension class |
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.
@noahnu changed, so that the initial extension class is used when not overridden
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.
LGTM
## [0.3.7](v0.3.6...v0.3.7) (2020-03-24) ### Bug Fixes * support call syntax for snapshot fixture overriding ([#160](#160)) ([4cf051c](4cf051c))
🎉 This PR is included in version 0.3.7 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Description
Support call syntax to easily switch extension class
Related Issues
N/A
Checklist
Additional Comments
No additional comments.