def test_has_instance(self): from typecheck import Typeclass tc = Typeclass(list, tuple) assert tc.has_instance(list) assert tc.has_instance(tuple) assert not tc.has_instance(set) tc.add_instance(set) assert tc.has_instance(set)
def test_add_instance(self): from typecheck import Typeclass tc = Typeclass(list, set, tuple) interface_before = tc.interface() tc.add_instance(dict) # Adding an instance shouldn't chance the interface... assert interface_before == tc.interface() # but it should change the instances list assert dict in tc.instances()