File: test_hash.py

package info (click to toggle)
python-inline-snapshot 0.32.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,900 kB
  • sloc: python: 11,339; makefile: 40; sh: 36
file content (55 lines) | stat: -rw-r--r-- 1,493 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from inline_snapshot._inline_snapshot import snapshot
from inline_snapshot.testing._example import Example


def test_max_hash():
    Example(
        {
            "tests/test_something.py": """\
from inline_snapshot import external
def test_a():
    assert "a" == external()
""",
            "pyproject.toml": """\
[tool.inline-snapshot]
hash-length=64
default-storage="hash"
""",
        }
    ).run_inline(
        ["--inline-snapshot=create"],
        changed_files=snapshot(
            {
                ".inline-snapshot/external/ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb.txt": "a",
                "tests/test_something.py": """\
from inline_snapshot import external
def test_a():
    assert "a" == external("hash:ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb.txt")
""",
            }
        ),
    )


def test_same_hash():
    Example(
        """\
from inline_snapshot import external
def test_a():
    assert "a" == external("hash:")
    assert "a" == external("hash:")
""",
    ).run_inline(
        ["--inline-snapshot=create"],
        changed_files=snapshot(
            {
                ".inline-snapshot/external/ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb.txt": "a",
                "tests/test_something.py": """\
from inline_snapshot import external
def test_a():
    assert "a" == external("hash:ca978112ca1b*.txt")
    assert "a" == external("hash:ca978112ca1b*.txt")
""",
            }
        ),
    )