File: test_xfail.py

package info (click to toggle)
python-inline-snapshot 0.29.0-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 1,400 kB
  • sloc: python: 8,877; makefile: 37; sh: 30
file content (84 lines) | stat: -rw-r--r-- 2,260 bytes parent folder | download | duplicates (3)
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
from inline_snapshot import snapshot
from inline_snapshot.testing import Example


def test_xfail_without_condition():

    Example(
        """\
import pytest

@pytest.mark.xfail
def test_a():
    assert 1==snapshot(5)
"""
    ).run_pytest(
        ["--inline-snapshot=fix"],
        report=snapshot(""),
        returncode=snapshot(0),
        stderr=snapshot(""),
        changed_files=snapshot({}),
    )


def test_xfail_True():
    Example(
        """\
import pytest
from inline_snapshot import snapshot

@pytest.mark.xfail(True,reason="...")
def test_a():
    assert 1==snapshot(5)
"""
    ).run_pytest(
        ["--inline-snapshot=fix"],
        report=snapshot(""),
        returncode=snapshot(0),
        stderr=snapshot(""),
        changed_files=snapshot({}),
    )


def test_xfail_False():
    Example(
        """\
import pytest
from inline_snapshot import snapshot

@pytest.mark.xfail(False,reason="...")
def test_a():
    assert 1==snapshot(5)
"""
    ).run_pytest(
        ["--inline-snapshot=fix"],
        report=snapshot(
            """\
-------------------------------- Fix snapshots ---------------------------------
+-------------------------- tests/test_something.py ---------------------------+
| @@ -3,4 +3,4 @@                                                              |
|                                                                              |
|                                                                              |
|  @pytest.mark.xfail(False,reason="...")                                      |
|  def test_a():                                                               |
| -    assert 1==snapshot(5)                                                   |
| +    assert 1==snapshot(1)                                                   |
+------------------------------------------------------------------------------+
These changes will be applied, because you used fix\
"""
        ),
        returncode=snapshot(1),
        stderr=snapshot(""),
        changed_files=snapshot(
            {
                "tests/test_something.py": """\
import pytest
from inline_snapshot import snapshot

@pytest.mark.xfail(False,reason="...")
def test_a():
    assert 1==snapshot(1)
"""
            }
        ),
    )