Example #1
0
def equality():
    Assert(1) == 1
    Assert(1) != 0
    with Assert.raises(AssertionError):
        Assert(1) == 0
    with Assert.raises(AssertionError):
        Assert(1) != 1
Example #2
0
def identity():
    Assert(True).is_(True)
    Assert(False).is_not(True)
    Assert([]).is_not([])
    with Assert.raises(AssertionError):
        Assert(False).is_(True)
    with Assert.raises(AssertionError):
        Assert(True).is_not(True)
    with Assert.raises(AssertionError):
        Assert([]).is_([])
Example #3
0
def contains():
    1 in Assert([0, 1, 2])
    Assert(1).in_([0, 1, 2])
    Assert(3).not_in([0, 1, 2])
    with Assert.raises(AssertionError):
        3 in Assert([0, 1, 2])
    with Assert.raises(AssertionError):
        Assert(3).in_([0, 1, 2])
    with Assert.raises(AssertionError):
        Assert(1).not_in([0, 1, 2])
Example #4
0
def raises():
    try:
        with Assert.raises(RuntimeError):
            pass
    except AssertionError:
        pass
    else:
        raise AssertionError("didn't fail for missing exception")
Example #5
0
def compare():
    Assert(1) > 0
    Assert(0) < 1
    Assert(1) >= 0
    Assert(1) >= 1
    Assert(0) <= 0
    Assert(0) <= 1
    with Assert.raises(AssertionError):
        Assert(0) > 1
    with Assert.raises(AssertionError):
        Assert(1) < 0
    with Assert.raises(AssertionError):
        Assert(0) >= 1
    with Assert.raises(AssertionError):
        Assert(0) >= 1
    with Assert.raises(AssertionError):
        Assert(1) <= 0
    with Assert.raises(AssertionError):
        Assert(1) <= 0