File: test_ci.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 (66 lines) | stat: -rw-r--r-- 1,935 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
from inline_snapshot import snapshot
from inline_snapshot.testing._example import Example


def test_ci_run():
    e = Example(
        """
from inline_snapshot import snapshot
def test_something():
    assert type(snapshot(5)) is int

    """
    )

    e.run_pytest(
        env={"CI": "true"},
        report=snapshot(
            """\
INFO: CI run was detected because environment variable "CI" was defined.
INFO: inline-snapshot runs with --inline-snapshot=disable by default in CI.\
"""
        ),
    )


def test_ci_and_fix():
    Example(
        """
from inline_snapshot import snapshot
def test_something():
    assert 5==snapshot(2)

    """
    ).run_pytest(
        ["--inline-snapshot=fix"],
        env={"CI": "true"},
        report=snapshot(
            """\
-------------------------------- Fix snapshots ---------------------------------
+----------------------------- test_something.py ------------------------------+
| @@ -1,6 +1,6 @@                                                              |
|                                                                              |
|                                                                              |
|  from inline_snapshot import snapshot                                        |
|  def test_something():                                                       |
| -    assert 5==snapshot(2)                                                   |
| +    assert 5==snapshot(5)                                                   |
+------------------------------------------------------------------------------+
These changes will be applied, because you used fix\
"""
        ),
        returncode=1,
    )


def test_no_ci_run():
    Example(
        """
from inline_snapshot import snapshot
def test_something():
    assert not isinstance(snapshot(5),int)

    """
    ).run_pytest(
        env={"TEAMCITY_VERSION": "true", "PYCHARM_HOSTED": "true"},
    )