Skip to content

Commit

Permalink
Simple test for constructing arguments for methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Treora committed Jun 17, 2015
1 parent 9037b38 commit 8f30dac
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/test_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ def onlykwrgs(**kwargs):
kwarg_list = [{}, {}, {'a': 1, 'b': 'fo', 'c': 9}, {'c': 3}, {}, {}, {}, {}]


class SomeClass:
def bla(self, a, b, c):
return a, b, c


# ####################### Tests #############################################

@pytest.mark.parametrize("function, name", zip(functions, names), ids=ids)
Expand Down Expand Up @@ -237,7 +242,6 @@ def test_construct_arguments_completes_kwargs_from_options():
args, kwargs = s.construct_arguments([2, 4], {}, {'c': 6})
assert args == [2, 4]
assert kwargs == {'c': 6}

s = Signature(complex_function_name)
args, kwargs = s.construct_arguments([], {'c': 6, 'b': 7}, {'a': 1})
assert args == []
Expand Down Expand Up @@ -302,6 +306,13 @@ def test_construct_arguments_does_not_raise_for_missing_defaults():
s.construct_arguments([], {}, {})


def test_construct_arguments_for_bound_method():
s = Signature(SomeClass.bla)
args, kwargs = s.construct_arguments([1], {'b': 2}, {'c': 3}, bound=True)
assert args == [1]
assert kwargs == {'b': 2, 'c': 3}


@pytest.mark.parametrize('func,expected', [
(foo, "foo()"),
(bariza, "bariza(a, b, c)"),
Expand Down

0 comments on commit 8f30dac

Please sign in to comment.