File: test_builder.py

package info (click to toggle)
python-inline-snapshot 0.32.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,900 kB
  • sloc: python: 11,339; makefile: 40; sh: 36
file content (34 lines) | stat: -rw-r--r-- 697 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
from inline_snapshot import snapshot
from inline_snapshot.testing._example import Example


def test_default_arg():

    e = Example(
        {
            "conftest.py": """\
from inline_snapshot.plugin import customize

class InlineSnapshotPlugin:
    @customize
    def handler(self,value,builder):
        if value==5:
            return builder.with_default(5,builder.create_code("8"))
""",
            "test_a.py": """\
from inline_snapshot import snapshot
def test_a():
    assert 5==snapshot()
""",
        }
    )

    e.run_inline(
        ["--inline-snapshot=create"],
        raises=snapshot(
            """\
UsageError:
default value can not be an Custom value\
"""
        ),
    )