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
|
from inline_snapshot import snapshot
from inline_snapshot.testing import Example
file_to_trim = {
"test_a.py": """\
from inline_snapshot import snapshot
def test_a():
assert 1 <= snapshot(5)
assert 1 == snapshot(2)
""",
}
trimmed_files = snapshot(
{
"test_a.py": """\
from inline_snapshot import snapshot
def test_a():
assert 1 <= snapshot(1)
assert 1 == snapshot(2)
"""
}
)
def test_config_pyproject():
Example(
{
**file_to_trim,
"pyproject.toml": """
[tool.inline-snapshot]
default-flags = ["trim"]
""",
}
).run_pytest(changed_files=trimmed_files, returncode=snapshot(1))
def test_config_env():
e = Example(file_to_trim)
e.run_pytest(
env={"INLINE_SNAPSHOT_DEFAULT_FLAGS": "trim"},
changed_files=trimmed_files,
returncode=snapshot(1),
)
e.run_pytest(
stdin=b"\n",
env={"INLINE_SNAPSHOT_DEFAULT_FLAGS": "trim"},
changed_files=trimmed_files,
returncode=snapshot(1),
)
def test_shortcuts():
Example(
{
**file_to_trim,
"pyproject.toml": """
[tool.inline-snapshot.shortcuts]
strim=["trim"]
""",
}
).run_pytest(["--strim"], changed_files=trimmed_files, returncode=snapshot(1))
def test_default_shortcuts():
Example(
{
**file_to_trim,
"pyproject.toml": """
""",
}
).run_pytest(
["--fix"],
changed_files=snapshot(
{
"test_a.py": """\
from inline_snapshot import snapshot
def test_a():
assert 1 <= snapshot(5)
assert 1 == snapshot(1)
"""
}
),
returncode=1,
)
|