summaryrefslogtreecommitdiffstats
path: root/src/test/pybind/assertions.py
blob: 719700f3ab71ae8a701919d39029a829f7af33af (plain)
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
def assert_equal(a, b):
    assert a == b

def assert_not_equal(a, b):
    assert a != b

def assert_greater(a, b):
    assert a > b

def assert_greater_equal(a, b):
    assert a >= b

def assert_raises(excClass, callableObj, *args, **kwargs):
    """
    Like unittest.TestCase.assertRaises, but returns the exception.
    """
    try:
        callableObj(*args, **kwargs)
    except excClass as e:
        return e
    else:
        if hasattr(excClass, '__name__'):
            excName = excClass.__name__
        else:
            excName = str(excClass)
        raise AssertionError("%s not raised" % excName)