コード例 #1
0
ファイル: asserts.py プロジェクト: whilp/schluck
def equality():
    Assert(1) == 1
    Assert(1) != 0
    with Assert.raises(AssertionError):
        Assert(1) == 0
    with Assert.raises(AssertionError):
        Assert(1) != 1
コード例 #2
0
ファイル: asserts.py プロジェクト: whilp/schluck
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_([])
コード例 #3
0
ファイル: asserts.py プロジェクト: whilp/schluck
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])
コード例 #4
0
ファイル: asserts.py プロジェクト: whilp/schluck
def raises():
    try:
        with Assert.raises(RuntimeError):
            pass
    except AssertionError:
        pass
    else:
        raise AssertionError("didn't fail for missing exception")
コード例 #5
0
ファイル: asserts.py プロジェクト: whilp/schluck
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