def test_values_application_passes_keyword_arguments_to_proc(): proc = Mock() values = Values(a=1, b=2, c=3) values.__apply__(proc) proc.assert_called_once_with(a=1, b=2, c=3)
def test_values_application_passes_positional_arguments_to_proc(): proc = Mock() values = Values(1, 2, 3) values.__apply__(proc) proc.assert_called_once_with(1, 2, 3)
def test_can_combine_values_sequentially(): first = Values(1, 2, 3) second = Values('x', 'y', 'z') proc = Mock() first.append(second).__apply__(proc) proc.assert_called_once_with(1, 2, 3, 'x', 'y', 'z')
def test_can_combine_keywordvalues_sequentially(): first = Values(a=1, b=2, c=3) second = Values(x=1, y=2, z=3) proc = Mock() first.append(second).__apply__(proc) proc.assert_called_once_with(a=1, b=2, c=3, x=1, y=2, z=3)
def permutation_wrapper(f): the_combination = compose( f, lambda *args, **kwargs: Values(*permute(args))) n = get_arity(f) assert n.fixed() == len(permspec) return restrict_arity(the_combination, n)
def the_combination(*args, **kwargs): t.check(len(args)) i = len(args) - m.min fv = Values(f(*args[:i], **kwargs)) gv = Values(g(*args[i:], **kwargs)) return fv.append(gv)
def the_combination(*args, **kwargs): n.check(len(args)) fv = Values(f(*args, **kwargs)) gv = Values(g(*args, **kwargs)) return fv.append(gv)
def the_combination(*args, **kwargs): m.check(len(args)) return Values(*(args[:i] + args[i + 1:]), **kwargs)
def poly(*args): results = [] for x in args: results.extend([1, x, x * x]) return Values(*results)
def test_compose_zero_funcs(): h = compose() assert h(1) == Values(1)
def test_values_application_returns_result_of_proc(): proc = Mock() result = Values().__apply__(proc) proc.assert_called_once() assert result == proc.return_value
def test_repr_of_values_is(): values = Values(1, 'two', c='cee') assert repr(values) == "Values(1, 'two', c='cee')"
def bar(): return Values(1, 2, c=3)
def test_values_with_values_argument_returns_same_values(): val1 = Values(1, 2) val2 = Values(val1) assert apply(make_list, val1) == apply(make_list, val2)