Skip to content
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

feat: allow extensions to override snapshot equality check #548

Merged
merged 4 commits into from
Jan 14, 2022

Conversation

noahnu
Copy link
Collaborator

@noahnu noahnu commented Aug 29, 2021

Description

Allow extensions to override snapshot equality check. This is to enable adding "tolerance" to the check, as well as to satisfy use cases such as visual regression testing.

Related Issues

Checklist

  • This PR has sufficient documentation.
  • This PR has sufficient test coverage.
  • This PR title satisfies semantic convention.

Additional Comments

No additional comments.

@codecov
Copy link

codecov bot commented Aug 29, 2021

Codecov Report

Merging #548 (0e27895) into master (ee8edaa) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #548   +/-   ##
=======================================
  Coverage   99.91%   99.91%           
=======================================
  Files          19       19           
  Lines        1142     1145    +3     
=======================================
+ Hits         1141     1144    +3     
  Misses          1        1           

Comment on lines +78 to +84
def test_updated_snapshots(generate_snapshots):
_, testdir, initial = generate_snapshots
testdir.makepyfile(test_file=initial["failed"])
result = testdir.runpytest("-v", "--snapshot-update")
result.stdout.re_match_lines((r"1 snapshot updated\."))
assert result.ret == 0
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is failing locally for me. For some reason, the serialized data is referring to the old value. Some odd caching issue somewhere.


def test_updated_snapshots(generate_snapshots):
_, testdir, initial = generate_snapshots
testdir.makepyfile(test_file=initial["failed"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not be updating the saved file as expected that's why the test_approximate_match is passing but test_failed_snapshots and test_updated_snapshots are failing

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed via pdb that's not it. It looks like a python bug, or maybe from pytest's bytecode rewriting

@iamogbz
Copy link
Collaborator

iamogbz commented Oct 27, 2021

Is this really needed, I think support for customising the matched value is already possible with the snapshot matchers

Seen the posted discussion

@noahnu noahnu marked this pull request as ready for review January 14, 2022 02:35
@noahnu noahnu merged commit a44f1b9 into master Jan 14, 2022
@noahnu noahnu deleted the tolerance_expressions branch January 14, 2022 02:46
tophat-opensource-bot pushed a commit that referenced this pull request Jan 14, 2022
# [1.6.0](v1.5.0...v1.6.0) (2022-01-14)

### Features

* allow extensions to override snapshot equality check ([#548](#548)) ([a44f1b9](a44f1b9))
@tophat-opensource-bot
Copy link
Collaborator

🎉 This PR is included in version 1.6.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants