示例#1
0
    def _verify_special_methods(self, someobj):
        someobj_special_methods = self._fetch_special_methods(someobj)
        our_special_methods = self._fetch_special_methods(self.reference_obj)

        missing = set(our_special_methods).difference(set(someobj_special_methods))
        if missing:
            # someobj is lacking some method we need
            raise SignatureVerificationError, "%s lacks methods: %s" % (someobj, missing)

        for name, method in our_special_methods.items():
            if not is_signature_compatible(method, someobj_special_methods[name]):
                raise SignatureVerificationError, "%s signature for %s is incompatible" % (someobj, method)
示例#2
0
 def test_arg_optarg_kwargs_callable_compatible_with_mixed_everything_callable(
         self):
     self.assertEquals(
         True,
         is_signature_compatible(arg_optarg_kwargs_callable,
                                 mixed_everything_callable))
示例#3
0
 def test_arg_optarg_kwargs_callable_compatible_with_mixed_everything_callable(self):
     self.assertEquals(True, is_signature_compatible(arg_optarg_kwargs_callable, mixed_everything_callable))
示例#4
0
 def test_unboundmethod_signature_is_not_compatible_with_instancemeth(self):
     self.assertFalse(is_signature_compatible(DifferentMethods.instancemeth, self.obj.instancemeth))
示例#5
0
 def test_attrfunc_signature_is_not_compatible_with_class_unbound_method(self):
     self.assertFalse(is_signature_compatible(self.obj.attrfunc, DifferentMethods.instancemeth))
示例#6
0
 def test_instancemethod_signature_is_compatible_with_instancemethod_signature(self):
     self.assertTrue(is_signature_compatible(self.obj.instancemeth, DifferentMethods.staticmeth))
示例#7
0
 def test_bound_method_without_self_is_compatible_with_unbound(self):
     self.assertTrue(is_signature_compatible(self.obj.instancemeth, BoundWithoutSelf.staticmeth))
示例#8
0
 def test_static_signature_is_compatible_with_obj_class_sig(self):
     self.assertTrue(is_signature_compatible(self.obj.staticmeth, self.obj.classmeth))
示例#9
0
 def test_three_optarg_callable_not_compatible_with_two_optarg_callable_same_names(
         self):
     self.assertEquals(
         False,
         is_signature_compatible(three_optarg_callable,
                                 two_optarg_callable))
示例#10
0
 def test_three_arg_callable_compatible_with_optarg_callable_with_diff_names(
         self):
     self.assertEquals(
         True,
         is_signature_compatible(three_arg_callable,
                                 two_arg_one_optarg_callable_other))
示例#11
0
 def test_switched_optional_args_retain_compatibility(self):
     self.assertEquals(
         True,
         is_signature_compatible(two_optarg_callable,
                                 two_optarg_callable_switched))
示例#12
0
 def test_different_optarg_names_are_not_compatible(self):
     self.assertEquals(
         False,
         is_signature_compatible(two_arg_one_optarg_callable,
                                 two_arg_one_optarg_callable_other))
示例#13
0
 def test_kwargs_not_compatible_with_arg_optarg_kwargs(self):
     self.assertEquals(
         False,
         is_signature_compatible(all_kwargs_callable,
                                 arg_optarg_kwargs_callable))
示例#14
0
 def test_kwargs_compatible_with_optarg_kwargs(self):
     self.assertEquals(
         True,
         is_signature_compatible(all_kwargs_callable,
                                 optarg_kwargs_callable))
示例#15
0
 def test_arg_optarg_kwargs_compatibile_with_kwargs_only(self):
     self.assertEquals(
         True,
         is_signature_compatible(arg_optarg_kwargs_callable,
                                 all_kwargs_callable))
示例#16
0
 def test_all_varargs_is_not_compatibile_with_empty(self):
     self.assertEquals(False, is_signature_compatible(all_varargs_callable, empty_callable))
示例#17
0
 def test_three_args_varargs_is_compatible_with_three_args_varargs(self):
     self.assertEquals(True, is_signature_compatible(three_args_varargs_callable, three_args_varargs_callable))
示例#18
0
 def test_identical_signatures_are_compatible(self):
     self.assertEquals(
         True, is_signature_compatible(two_arg_callable1,
                                       two_arg_callable_2))
示例#19
0
 def test_static_signature_is_compatible_with_attrfunc(self):
     self.assertTrue(is_signature_compatible(self.obj.staticmeth, self.obj.attrfunc))
示例#20
0
 def test_optional_arg_keeps_signature_compatible(self):
     self.assertEquals(
         True,
         is_signature_compatible(two_arg_callable1,
                                 two_arg_one_optarg_callable))
示例#21
0
 def test_classmethod_signature_is_compatible_with_attrfunc(self):
     self.assertTrue(is_signature_compatible(DifferentMethods.classmeth, self.obj.attrfunc))
示例#22
0
 def test_three_arg_sig_incompatible_with_two(self):
     self.assertEquals(
         False,
         is_signature_compatible(three_arg_callable, two_arg_callable1))
示例#23
0
 def test_attrfunc_signature_is_compatible_with_obj_class_sig(self):
     self.assertTrue(is_signature_compatible(self.obj.attrfunc, self.obj.classmeth))
示例#24
0
 def test_two_arg_optarg_incompatible_with_three(self):
     self.assertEquals(
         False,
         is_signature_compatible(two_arg_one_optarg_callable,
                                 three_arg_callable))
示例#25
0
 def test_attrfunc_signature_is_compatible_with_instancemeth(self):
     self.assertTrue(is_signature_compatible(self.obj.attrfunc, self.obj.instancemeth))
示例#26
0
 def test_two_arg_is_compatible_with_two_optarg(self):
     self.assertEquals(
         True,
         is_signature_compatible(two_arg_callable1, two_optarg_callable))
示例#27
0
 def test_vararg_kwargs_incompatible_with_everything_but_itself(self):
     everything_but_varargs_kwargs_callable = filter(lambda x: x.func_name != "varargs_kwargs_callable", everything)
     for func in everything_but_varargs_kwargs_callable:
         self.assertEquals(False, is_signature_compatible(varargs_kwargs_callable, func), "%s is compatible!" % func.func_name)
示例#28
0
 def test_two_optarg_is_not_compatible_with_two_arg(self):
     self.assertEquals(
         False,
         is_signature_compatible(two_optarg_callable, two_arg_callable1))
示例#29
0
 def test_kwargs_compatible_with_optarg_kwargs(self):
     self.assertEquals(True, is_signature_compatible(all_kwargs_callable, optarg_kwargs_callable))
示例#30
0
 def test_any_fixed_arg_compatible_with_all_varargs(self):
     self.assertEquals(
         True,
         is_signature_compatible(two_arg_callable1, all_varargs_callable))
示例#31
0
 def test_two_fixed_args_incompatible_three_args_varargs(self):
     self.assertEquals(False, is_signature_compatible(two_arg_callable1, three_args_varargs_callable))
示例#32
0
 def test_two_fixed_args_incompatible_three_args_varargs(self):
     self.assertEquals(
         False,
         is_signature_compatible(two_arg_callable1,
                                 three_args_varargs_callable))
示例#33
0
 def test_all_varargs_is_compatibile_with_all_varargs(self):
     self.assertEquals(True, is_signature_compatible(all_varargs_callable, all_varargs_callable))
示例#34
0
 def test_all_varargs_is_not_compatibile_with_empty(self):
     self.assertEquals(
         False, is_signature_compatible(all_varargs_callable,
                                        empty_callable))
示例#35
0
 def test_all_varargs_is_not_compatibile_with_three_args_varargs(self):
     self.assertEquals(False, is_signature_compatible(all_varargs_callable, three_args_varargs_callable))
示例#36
0
 def test_all_varargs_is_compatibile_with_all_varargs(self):
     self.assertEquals(
         True,
         is_signature_compatible(all_varargs_callable,
                                 all_varargs_callable))
示例#37
0
 def test_static_signature_is_compatible_with_obj_instance_method(self):
     self.assertTrue(is_signature_compatible(self.obj.staticmeth, self.obj.instancemeth))
示例#38
0
 def test_three_args_varargs_is_compatible_with_three_args_varargs(self):
     self.assertEquals(
         True,
         is_signature_compatible(three_args_varargs_callable,
                                 three_args_varargs_callable))
示例#39
0
 def test_classmethod_signature_is_compatible_with_obj_instance_method(self):
     self.assertTrue(is_signature_compatible(DifferentMethods.classmeth, self.obj.instancemeth))
示例#40
0
 def test_all_varargs_is_not_compatibile_with_three_args_varargs(self):
     self.assertEquals(
         False,
         is_signature_compatible(all_varargs_callable,
                                 three_args_varargs_callable))
示例#41
0
 def test_classmethod_signature_is_compatible_with_classmethod_signature(self):
     self.assertTrue(is_signature_compatible(DifferentMethods.classmeth, DifferentMethods.staticmeth))
示例#42
0
 def test_static_signature_is_compatible_with_obj_class_sig(self):
     self.assertTrue(
         is_signature_compatible(self.obj.staticmeth, self.obj.classmeth))
示例#43
0
 def test_instancemethod_signature_is_compatible_with_obj_class_sig(self):
     self.assertTrue(is_signature_compatible(self.obj.instancemeth, self.obj.classmeth))
示例#44
0
 def test_static_signature_is_compatible_with_obj_instance_method(self):
     self.assertTrue(
         is_signature_compatible(self.obj.staticmeth,
                                 self.obj.instancemeth))
示例#45
0
 def test_instancemethod_signature_is_compatible_with_attrfunc(self):
     self.assertTrue(is_signature_compatible(self.obj.instancemeth, self.obj.attrfunc))
示例#46
0
 def test_static_signature_is_compatible_with_attrfunc(self):
     self.assertTrue(
         is_signature_compatible(self.obj.staticmeth, self.obj.attrfunc))
示例#47
0
 def test_attrfunc_signature_is_compatible_with_obj_instance_method(self):
     self.assertTrue(is_signature_compatible(self.obj.attrfunc, DifferentMethods.classmeth))
示例#48
0
 def test_classmethod_signature_is_compatible_with_obj_instance_method(
         self):
     self.assertTrue(
         is_signature_compatible(DifferentMethods.classmeth,
                                 self.obj.instancemeth))
示例#49
0
 def test_attrfunc_signature_is_compatible_with_attrfunc_signature(self):
     self.assertTrue(is_signature_compatible(self.obj.attrfunc, DifferentMethods.staticmeth))
示例#50
0
 def test_unbound_method_not_compatible_with_static(self):
     self.assertFalse(
         is_signature_compatible(DifferentMethods.instancemeth,
                                 self.obj.staticmeth))
示例#51
0
 def test_unboundmethod_signature_is_compatible_with_class_unbound_method(self):
     self.assertTrue(is_signature_compatible(DifferentMethods.instancemeth, DifferentMethods.instancemeth))
示例#52
0
 def test_bound_method_without_self_is_compatible_with_unbound(self):
     self.assertTrue(
         is_signature_compatible(self.obj.instancemeth,
                                 BoundWithoutSelf.staticmeth))
示例#53
0
 def test_every_func_compatible_with_varargs_kwargs(self):
     for func in everything:
         self.assertEquals(True, is_signature_compatible(func, varargs_kwargs_callable) )
示例#54
0
 def test_classmethod_signature_is_not_compatible_with_class_unbound_method(
         self):
     self.assertFalse(
         is_signature_compatible(self.obj.classmeth,
                                 DifferentMethods.instancemeth))
示例#55
0
 def test_three_arg_optarg_callable_compatible_with_mixed_everything_callable(self):
     self.assertEquals(False, is_signature_compatible(three_optarg_callable, mixed_everything_callable))
示例#56
0
 def test_classmethod_signature_is_compatible_with_classmethod_signature(
         self):
     self.assertTrue(
         is_signature_compatible(self.obj.classmeth,
                                 DifferentMethods.staticmeth))
示例#57
0
 def test_arg_optarg_kwargs_compatibile_with_kwargs_only(self):
     self.assertEquals(True, is_signature_compatible(arg_optarg_kwargs_callable, all_kwargs_callable))
示例#58
0
 def test_classmethod_signature_is_compatible_with_attrfunc(self):
     self.assertTrue(
         is_signature_compatible(self.obj.classmeth, self.obj.attrfunc))
示例#59
0
 def test_kwargs_not_compatible_with_arg_optarg_kwargs(self):
     self.assertEquals(False, is_signature_compatible(all_kwargs_callable, arg_optarg_kwargs_callable))
示例#60
0
 def test_instancemethod_signature_is_compatible_with_obj_class_sig(self):
     self.assertTrue(
         is_signature_compatible(self.obj.instancemeth, self.obj.classmeth))