File: test_example_raises.py

package info (click to toggle)
pytest-check 2.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 432 kB
  • sloc: python: 1,775; sh: 17; makefile: 6
file content (32 lines) | stat: -rw-r--r-- 668 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
from pytest_check import check, raises


def test_raises_top_level_fail():
    with raises(AssertionError):
        x = 3
        assert 1 < x < 4


def test_raises_top_level_pass():
    with raises(AssertionError):
        x = 4
        assert 1 < x < 3


def test_raises_check_level_fail():
    with check.raises(AssertionError):
        x = 3
        assert 1 < x < 4


def test_raises_check_level_pass():
    with check.raises(AssertionError):
        x = 4
        assert 1 < x < 3


def test_raises_exception_value():
    with check.raises(ValueError) as e:
        raise ValueError("This is a ValueError")

    check.equal(str(e.value), "This is a ValueError")