Example #1
0
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)
Example #2
0
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)
Example #3
0
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')
Example #4
0
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)
Example #5
0
    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)
Example #6
0
 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)
Example #7
0
 def the_combination(*args, **kwargs):
     n.check(len(args))
     fv = Values(f(*args, **kwargs))
     gv = Values(g(*args, **kwargs))
     return fv.append(gv)
Example #8
0
 def the_combination(*args, **kwargs):
     m.check(len(args))
     return Values(*(args[:i] + args[i + 1:]), **kwargs)
Example #9
0
 def poly(*args):
     results = []
     for x in args:
         results.extend([1, x, x * x])
     return Values(*results)
Example #10
0
def test_compose_zero_funcs():
    h = compose()
    assert h(1) == Values(1)
Example #11
0
def test_values_application_returns_result_of_proc():
    proc = Mock()
    result = Values().__apply__(proc)

    proc.assert_called_once()
    assert result == proc.return_value
Example #12
0
def test_repr_of_values_is():
    values = Values(1, 'two', c='cee')
    assert repr(values) == "Values(1, 'two', c='cee')"
Example #13
0
 def bar():
     return Values(1, 2, c=3)
Example #14
0
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)