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
|
import pytest
from executing import is_pytest_compatible
from inline_snapshot import snapshot
from inline_snapshot.testing import Example
@pytest.mark.skipif(
is_pytest_compatible(),
reason="this is only a problem when executing can return None",
)
def test_without_node():
Example(
{
"conftest.py": """\
from inline_snapshot.plugin import customize
@customize
def handler(value,builder):
if value=="foo":
return builder.create_code("'foo'")
""",
"test_example.py": """\
from inline_snapshot import snapshot
from dirty_equals import IsStr
def test_foo():
assert "not_foo" == snapshot(IsStr())
""",
}
).run_pytest()
def test_custom_default_case_in_ValueToCustom(executing_used):
Example(
"""\
from inline_snapshot import snapshot
from dataclasses import dataclass
@dataclass
class A:
a:int=5
def test_something():
assert A(a=3) == snapshot(A(a=5)),"not equal"
"""
).run_inline(
changed_files=snapshot({}),
raises=snapshot(
"""\
AssertionError:
not equal\
"""
),
)
def test_tuple_case_in_ValueToCustom(executing_used):
Example(
"""\
from inline_snapshot import snapshot
from dataclasses import dataclass
@dataclass
class A:
a:int=5
def test_something():
assert (1,2) == snapshot((1,2)),"not equal"
"""
).run_inline(
changed_files=snapshot({}),
raises=snapshot(None),
)
|