File: test_warns.py

package info (click to toggle)
python-inline-snapshot 0.23.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,116 kB
  • sloc: python: 6,888; makefile: 34; sh: 28
file content (33 lines) | stat: -rw-r--r-- 711 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
import warnings

from inline_snapshot import snapshot
from inline_snapshot.extra import warns


def test_warns():

    def warning():
        warnings.warn_explicit(
            message="bad things happen",
            category=SyntaxWarning,
            filename="file.py",
            lineno=5,
        )

    with warns(
        snapshot([("file.py", 5, "SyntaxWarning: bad things happen")]),
        include_line=True,
        include_file=True,
    ):
        warning()

    with warns(
        snapshot([("file.py", "SyntaxWarning: bad things happen")]),
        include_file=True,
    ):
        warning()

    with warns(
        snapshot(["SyntaxWarning: bad things happen"]),
    ):
        warning()