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
|
from inline_snapshot import snapshot
from inline_snapshot.testing._example import Example
def test_repr():
Example(
"""\
from inline_snapshot import snapshot
from inline_snapshot.extra import Transformed
def test_a():
n=Transformed(sorted,snapshot())
assert [3,5,2] == n
assert repr(n) == snapshot()
"""
).run_inline(
["--inline-snapshot=create"],
changed_files=snapshot(
{
"tests/test_something.py": """\
from inline_snapshot import snapshot
from inline_snapshot.extra import Transformed
def test_a():
n=Transformed(sorted,snapshot([2, 3, 5]))
assert [3,5,2] == n
assert repr(n) == snapshot("Transformed(sorted, [2, 3, 5])")
"""
}
),
).replace(
"[3,5,2]", "[3,6,2]"
).run_pytest(
error=snapshot(
"""\
> assert [3,6,2] == n
E assert [3, 6, 2] == Transformed(sorted, [2, 3, 5], should_be=[2, 3, 6])
"""
),
returncode=1,
)
|