예제 #1
0
 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)
예제 #2
0
    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)
예제 #3
0
 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()
예제 #4
0
    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()