def equality(): Assert(1) == 1 Assert(1) != 0 with Assert.raises(AssertionError): Assert(1) == 0 with Assert.raises(AssertionError): Assert(1) != 1
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_([])
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])
def raises(): try: with Assert.raises(RuntimeError): pass except AssertionError: pass else: raise AssertionError("didn't fail for missing exception")
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