File: test_snapshot_option_ignore_file_extensions.py

package info (click to toggle)
python-syrupy 4.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,368 kB
  • sloc: python: 5,978; makefile: 3
file content (27 lines) | stat: -rw-r--r-- 888 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from pathlib import Path


def test_ignore_file_extensions(testdir):
    # Generate initial snapshot file
    testdir.makepyfile(
        test_file=(
            """
            def test_case(snapshot):
                assert snapshot == "some-value"
            """
        ),
    )
    result = testdir.runpytest("-v", "--snapshot-update")
    result.stdout.re_match_lines((r"1 snapshot generated\.",))
    assert result.ret == 0

    # Duplicate the snapshot file with "dvc" file extension
    snapshot_file = Path(testdir.tmpdir, "__snapshots__", "test_file.ambr")
    dvc_file = snapshot_file.with_suffix(".ambr.dvc")
    dvc_file.write_text(snapshot_file.read_text())

    # Run with ignored file extension
    result = testdir.runpytest(
        "-v", "--snapshot-details", "--snapshot-ignore-file-extensions=dvc"
    )
    result.stdout.no_re_match_line(r".*1 snapshot unused.*")