def test_varkw_are_forwarded(self): obj = wire(varkwargs_func, {"a": 5}, 1, a=2, b=3) self.assertEquals((1, {"a":2, "b":3}), obj)
def test_varargs_and_varkw_are_forwarded(self): obj = wire(varboth_func, {}, 1, a=2, b=3) self.assertEquals(((1,), {"a":2, "b":3}), obj)
def test_arguments_in_excess_do_not_interfer_with_instantiation(self): d = { "some":1, "argument": 2} obj = wire(func_to_wire, d, 1, 2)
def test_varargs_are_forwarded(self): obj = wire(varposargs_func, {}, 1, 2, 3) self.assertEquals((1, (2, 3)), obj)
def test_positional_and_kw_arguments_dont_clash(self): d = { "pos1":1, "pos2": 2, "kw1": 3 } obj = wire(func_to_wire, d, 5, pos2="y") self.assertEquals( (5, "y" ,3, "b"), obj)
def test_positional_additional_kw_arguments_have_precedence(self): d = { "pos1":1, "pos2": 2, "kw1": 3 } obj = wire(func_to_wire, d, pos2="y") self.assertEquals( (1, "y" ,3, "b"), obj)
def test_missing_args_from_mapping_are_fetched_from_defaults(self): d = { "pos1":1, "pos2": 2, "kw1": 3 } obj = wire(func_to_wire, d) self.assertEquals( (1,2,3,"b"), obj )
def test_all_nonvariable_arguments_can_be_wired_from_dictionary(self): d = { "pos1":1, "pos2": 2, "kw1": 3, "kw2": 4 } obj = wire(func_to_wire, d) self.assertEquals( (1,2,3,4), obj )
def wire(self, callable_obj, *args, **kwargs): return wire(callable_obj, self.mergingproxy, *args, **kwargs)