Closed iamogbz closed 1 year ago
Limit the amount of characters used when comparing line diffs.
Can be validated by changing DIFF_LINE_WIDTH_LIMIT to a value like 1000000 and running inv test -t test_diff_large_lines
DIFF_LINE_WIDTH_LIMIT
1000000
inv test -t test_diff_large_lines
test_unicode
def test_large_binary_diff(snapshot): b = b"\x01" * 1000000 assert b == snapshot.use_extension(SingleFileSnapshotExtension)
(syrupy-py3.11) ➜ syrupy git:(test-single-file-fix) ✗ inv test -vv -t test_large_binary_diff ============================== test session starts ============================== platform darwin -- Python 3.11.4, pytest-7.4.0, pluggy-1.2.0 -- /Users/Emmanuel/Sources/github/tophat/syrupy/.venv/bin/python cachedir: .pytest_cache benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000) rootdir: /Users/Emmanuel/Sources/github/tophat/syrupy configfile: pyproject.toml plugins: syrupy-4.0.7, xdist-3.3.1, benchmark-4.0.0 collected 259 items / 258 deselected / 1 selected tests/syrupy/extensions/test_single_file.py::test_large_binary_diff FAILED =================================== FAILURES ==================================== ____________________________ test_large_binary_diff _____________________________ snapshot = SnapshotAssertion(name='snapshot', num_executions=0) def test_large_binary_diff(snapshot): b = b"\x01" * 1000000 > assert b == snapshot.use_extension(SingleFileSnapshotExtension) E AssertionError: assert [+ received] == [- snapshot] E Snapshot 'test_large_binary_diff' does not exist! E + b'\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x... tests/syrupy/extensions/test_single_file.py:77: AssertionError ---------------------------- snapshot report summary ---------------------------- 1 snapshot failed. ============================ short test summary info ============================ FAILED tests/syrupy/extensions/test_single_file.py::test_large_binary_diff - AssertionError: assert [+ received] == [- snapshot] ======================= 1 failed, 258 deselected in 0.21s =======================
Follow up to #776
:tada: This PR is included in version 4.0.8 :tada:
The release is available on:
v4.0.8
Your semantic-release bot :package::rocket:
Description
Limit the amount of characters used when comparing line diffs.
Can be validated by changing
DIFF_LINE_WIDTH_LIMIT
to a value like1000000
and runninginv test -t test_diff_large_lines
test_unicode
Related Issues
Checklist
Additional Comments
Follow up to #776