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
|
from inline_snapshot import snapshot
from inline_snapshot.testing._example import Example
def test_use_snapshot_updates():
expected_report = snapshot("")
Example(
{
"pyproject.toml": f"""\
[tool.inline-snapshot]
""",
"test_a.py": """\
from inline_snapshot import snapshot
def test_a():
assert 5 == snapshot(2+3)
""",
}
).run_pytest(
["--inline-snapshot=review"], changed_files=snapshot({}), report=expected_report
).run_pytest(
["--inline-snapshot=report"], changed_files=snapshot({}), report=expected_report
).run_pytest(
["--inline-snapshot=update"],
changed_files=snapshot(
{
"test_a.py": """\
from inline_snapshot import snapshot
def test_a():
assert 5 == snapshot(5)
"""
}
),
report=snapshot(
"""\
------------------------------- Update snapshots -------------------------------
+--------------------------------- test_a.py ----------------------------------+
| @@ -1,4 +1,4 @@ |
| |
| from inline_snapshot import snapshot |
| |
| def test_a(): |
| - assert 5 == snapshot(2+3) |
| + assert 5 == snapshot(5) |
+------------------------------------------------------------------------------+
These changes will be applied, because you used update\
"""
),
)
|