File: test_module_name.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 (59 lines) | stat: -rw-r--r-- 1,239 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
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
"""Tests for module_name_of function coverage."""

from inline_snapshot import snapshot
from inline_snapshot.testing import Example


def test_module_name_init_py_with_snapshot():
    """Test module_name_of when __init__.py itself contains the snapshot call."""
    Example(
        {
            "tests/__init__.py": "",
            "tests/mypackage/b.py": """\
from dataclasses import dataclass

@dataclass
class B:
    b:int
""",
            "tests/mypackage/__init__.py": """\
from inline_snapshot import snapshot
from dataclasses import dataclass

@dataclass
class A:
    a:int

s = snapshot()
""",
            "tests/test_something.py": """\
from inline_snapshot import snapshot

def test_a():
    from .mypackage import s,A
    from .mypackage.b import B
    assert s == [A(5),B(5)]
""",
        }
    ).run_pytest(
        ["--inline-snapshot=create"],
        changed_files=snapshot(
            {
                "tests/mypackage/__init__.py": """\
from inline_snapshot import snapshot
from dataclasses import dataclass

from tests.mypackage.b import B

@dataclass
class A:
    a:int

s = snapshot([A(a=5), B(b=5)])
"""
            }
        ),
        returncode=1,
    ).run_pytest(
        ["--inline-snapshot=disable"]
    )