File: test_raises.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 (27 lines) | stat: -rw-r--r-- 528 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
from inline_snapshot import snapshot
from inline_snapshot.extra import raises


def test_raises():
    with raises(snapshot("ZeroDivisionError: division by zero")):
        0 / 0

    with raises(snapshot("<no exception>")):
        pass

    with raises(
        snapshot(
            """\
ValueError:
with
two lines\
"""
        )
    ):
        raise ValueError("with\ntwo lines")

    with raises(snapshot("SystemExit: 1")):
        exit(1)

    with raises(snapshot("KeyboardInterrupt: ")):
        raise KeyboardInterrupt