File: test_xdist.py

package info (click to toggle)
python-inline-snapshot 0.23.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,116 kB
  • sloc: python: 6,888; makefile: 34; sh: 28
file content (109 lines) | stat: -rw-r--r-- 2,063 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
from inline_snapshot import snapshot


def test_xdist(project):

    project.setup(
        """\

def test_a():
    assert 1==snapshot()
"""
    )

    result = project.run("--inline-snapshot=create", "-n=auto")

    assert "\n".join(result.stderr.lines).strip() == snapshot(
        "ERROR: --inline-snapshot=create can not be combined with xdist"
    )

    assert result.ret == 4


def test_xdist_disabled(project):

    project.setup(
        """\

def test_a():
    assert 1==snapshot(1)
"""
    )

    result = project.run("-n=auto")

    assert result.report == snapshot(
        "INFO: inline-snapshot was disabled because you used xdist"
    )

    assert result.ret == 0


def test_xdist_and_disable(project):

    project.setup(
        """\

def test_a():
    assert 1==snapshot(2)
"""
    )

    result = project.run("-n=auto", "--inline-snapshot=disable")

    assert result.report == snapshot("")

    assert result.stderr.lines == snapshot([])

    assert result.ret == 1

    result = project.run("-n=auto", "--inline-snapshot=fix")

    assert result.report == snapshot("")

    assert result.stderr.lines == snapshot(
        ["ERROR: --inline-snapshot=fix can not be combined with xdist", ""]
    )

    assert result.ret == 4

    project.pyproject(
        """\
[tool.inline-snapshot]
default-flags = ["fix"]
"""
    )

    result = project.run("-n=auto")

    assert result.report == snapshot(
        "INFO: inline-snapshot was disabled because you used xdist"
    )

    assert result.stderr.lines == snapshot([])

    assert result.ret == 1


def test_xdist_zero_processes(project):

    project.setup(
        """\

def test_a():
    assert 1==snapshot(2)
"""
    )

    result = project.run("-n=0", "--inline-snapshot=short-report")

    result.assert_outcomes(failed=1, errors=1)

    assert result.report == snapshot(
        """\
Error: one snapshot has incorrect values (--inline-snapshot=fix)
You can also use --inline-snapshot=review to approve the changes interactively
"""
    )

    assert result.stderr.lines == snapshot([])