generated from tophat/new-project-kit
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For extremely large snapshot files, the diff algorithm is not very efficient. Until the algorithm can be modified to work with large files, there is now a --snapshot-diff-mode=disabled flag that can be specified to disable diffing on snapshot assertion failures.
- Loading branch information
Showing
4 changed files
with
82 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def testfile(testdir) -> pytest.Testdir: | ||
testdir.makepyfile( | ||
test_file=( | ||
""" | ||
def test_case(snapshot): | ||
assert snapshot == "some-value" | ||
""" | ||
), | ||
) | ||
return testdir | ||
|
||
|
||
def test_diff_mode_disabled_does_not_print_diff( | ||
testfile, | ||
): | ||
# Generate initial snapshot | ||
result = testfile.runpytest("-v", "--snapshot-update") | ||
result.stdout.re_match_lines((r"1 snapshot generated\.",)) | ||
assert result.ret == 0 | ||
|
||
# Modify snapshot to generate diff | ||
testfile.makepyfile( | ||
test_file=( | ||
""" | ||
def test_case(snapshot): | ||
assert snapshot == "some-other-value" | ||
""" | ||
), | ||
) | ||
|
||
# With diff we expect to see "some-other-value" | ||
result = testfile.runpytest("-v", "--snapshot-diff-mode=detailed") | ||
result.stdout.re_match_lines( | ||
( | ||
r".*- 'some-value'", | ||
r".*\+ 'some-other-value'", | ||
) | ||
) | ||
assert result.ret == 1 | ||
|
||
# Without diff we do not expect to see "some-other-value" | ||
result = testfile.runpytest("-v", "--snapshot-diff-mode=disabled") | ||
result.stdout.no_re_match_line(r".*- 'some-value'") | ||
result.stdout.no_re_match_line(r".*\+ 'some-other-value'") | ||
assert result.ret == 1 |