def test_failure_2(self): from typecheck import _TC_TypeError, Not try: check_type(Not(int, float), 4.0) except _TC_TypeError, e: assert e.right == Not(int, float) assert e.wrong == float
def test_success(self): from typecheck import Not check_type(Not(int), 4.0) check_type(Not(int, float), 'four') class A: pass class B: pass class C: pass check_type(Not(A, B, int), C())
def test_constructor(self): from typecheck import Not try: Not() except TypeError, e: assert str(e) == "__init__() takes at least 2 arguments (1 given)"
def test_failure_3(self): from typecheck import _TC_TypeError, Not class A: pass class B: pass class C(A, B): pass try: check_type(Not(A, B, int), C()) except _TC_TypeError, e: assert e.right == Not(A, B, int) assert e.wrong == C
def Xor(cond_1, cond_2): return Or(And(cond_1, Not(cond_2)), And(cond_2, Not(cond_1)))
def test_hash(self): from typecheck import Not, Or eq_tests = [(Not(int, float), Not(int, float)), (Not(int, float), Not(int, int, int, float)), (Not(int, int, int, float), Not(int, float)), (Not(int, float), Not(float, int)), (Not(Not(int, str), float), Not(float, Not(str, int)))] ne_tests = [(Not(float, str), Not(int, float)), (Not(int, float, str), Not(int, float)), (Not(int, float), Not(int, float, str)), (Not(int, float), Or(int, float)), (Not(Not(int, str), float), Not(int, str, float)), (Not(Not(int, float), Not(str, int)), Not(int, float, str))] self.multipleAssertEqualHashes(eq_tests, ne_tests)