Exemplo n.º 1
0
 def dic(obj):
     check_type(Dict(key=str, val=int), obj)
Exemplo n.º 2
0
 def dict2(obj):
     check_type(Dict( (int, int), float ), obj)
Exemplo n.º 3
0
 def dict1(obj):
     check_type(Dict( int, {int: float}), obj)
Exemplo n.º 4
0
 def test_hash(self):
     from typecheck import Dict
     
     class A(object): pass
     class B(A): pass
     
     eq_tests = [
         (Dict(str, int), Dict(str, int)),
         (Dict(str, A), Dict(str, A)),
         (Dict(str, Dict(str, int)), Dict(str, Dict(str, int))) ]
         
     ne_tests = [
         (Dict(str, int), Dict(int, str)),
         (Dict(str, Dict(str, int)), Dict(str, Dict(int, str))) ]
     
     test_hash(eq_tests, ne_tests)
Exemplo n.º 5
0
    def test_hash(self):
        from typecheck import Dict

        class A(object):
            pass

        eq_tests = [(Dict(str, int), Dict(str, int)),
                    (Dict(str, A), Dict(str, A)),
                    (Dict(str, Dict(str, int)), Dict(str, Dict(str, int)))]

        ne_tests = [(Dict(str, int), Dict(int, str)),
                    (Dict(str, Dict(str, int)), Dict(str, Dict(int, str)))]

        self.multipleAssertEqualHashes(eq_tests, ne_tests)
Exemplo n.º 6
0
    def test_equality(self):
        from typecheck import Dict

        class A(object):
            pass

        eq_tests = [(Dict(str, int), Dict(str, int)),
                    (Dict(str, A), Dict(str, A)),
                    (Dict(str, Dict(str, int)), Dict(str, Dict(str, int)))]

        ne_tests = [(Dict(str, int), Dict(int, str)), (Dict(str, int), {
            'a': 5
        }), (Dict(str, Dict(str, int)), Dict(str, Dict(int, str)))]

        self.multipleAssertEqual(eq_tests, ne_tests)