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

Compare serialized data in assertion compr & improve diff report #46

Merged
merged 9 commits into from
Dec 24, 2019

Conversation

noahnu
Copy link
Collaborator

@noahnu noahnu commented Dec 22, 2019

Partially addresses #22 by spliting diff reporting line by line, similar to jest snapshot diffs.

Addresses #21 by reading raw text from the snapshot file for line by line comparison.

@codecov
Copy link

codecov bot commented Dec 22, 2019

Codecov Report

Merging #46 into master will increase coverage by 32.4%.
The diff coverage is 70.83%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #46      +/-   ##
=========================================
+ Coverage   58.89%   91.3%   +32.4%     
=========================================
  Files          14      14              
  Lines         399     414      +15     
=========================================
+ Hits          235     378     +143     
+ Misses        164      36     -128
Impacted Files Coverage Δ
src/syrupy/serializers/base.py 98.52% <ø> (+50.33%) ⬆️
src/syrupy/serializers/yaml.py 98.18% <100%> (+44.12%) ⬆️
src/syrupy/serializers/raw_single.py 79.48% <100%> (+6.51%) ⬆️
src/syrupy/assertion.py 80.72% <27.77%> (+26.55%) ⬆️
src/syrupy/terminal.py 92.3% <50%> (+46.85%) ⬆️
src/syrupy/session.py 96.84% <0%> (+20.31%) ⬆️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a5f46e5...ae64458. Read the comment docs.

@noahnu noahnu requested a review from iamogbz December 22, 2019 20:04
.coveragerc Outdated Show resolved Hide resolved

def test_raises_error_for_unserializable_data(snapshot_png):
with pytest.raises(ValueError):
assert "not a byte string" == snapshot_png
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not sure if it's best to throw an error here, or consider this a failed snapshot.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We could wrap the serialization with an error handler and compare the raw values if it fails

src/syrupy/assertion.py Outdated Show resolved Hide resolved
src/syrupy/serializers/yaml.py Outdated Show resolved Hide resolved
tests/test_snapshots.py Show resolved Hide resolved

def test_raises_error_for_unserializable_data(snapshot_png):
with pytest.raises(ValueError):
assert "not a byte string" == snapshot_png
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could wrap the serialization with an error handler and compare the raw values if it fails

tasks.py Show resolved Hide resolved
@noahnu noahnu requested a review from iamogbz December 24, 2019 01:20
iamogbz
iamogbz previously approved these changes Dec 24, 2019
* chore: do not report on implicitly covered lines

* wip: more explicit

* wip: all is not what it seems

* wip: run coverage without pytest-cov

* wip: fix coverage source config

* wip: fix coverage source config
@noahnu noahnu merged commit 5bef286 into master Dec 24, 2019
@noahnu noahnu deleted the dont_serialize_21 branch December 24, 2019 17:07
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.

2 participants