Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved all tests with FunCTIonWithCAPItals in the py3 file #522

Merged
merged 1 commit into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 8 additions & 27 deletions tests/test_config/test_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ def complex_function_name(a=1, b='fo', c=9):
return a, b, c


# noinspection PyPep8Naming
def FunCTIonWithCAPItals(a, b, c=3, **kwargs):
return a, b, c, kwargs


def _name_with_underscore_(fo, bar, *baz):
return fo, bar, baz

Expand All @@ -50,30 +45,30 @@ def onlykwrgs(**kwargs):

renamed = old_name

functions = [foo, bariza, complex_function_name, FunCTIonWithCAPItals,
functions = [foo, bariza, complex_function_name,
_name_with_underscore_, __double_underscore__, old_name, renamed]

ids = ['foo', 'bariza', 'complex_function_name', 'FunCTIonWithCAPItals',
ids = ['foo', 'bariza', 'complex_function_name',
'_name_with_underscore_', '__double_underscore__', 'old_name',
'renamed']

names = ['foo', 'bariza', 'complex_function_name', 'FunCTIonWithCAPItals',
names = ['foo', 'bariza', 'complex_function_name',
'_name_with_underscore_', '__double_underscore__', 'old_name',
'old_name']

arguments = [[], ['a', 'b', 'c'], ['a', 'b', 'c'], ['a', 'b', 'c'],
arguments = [[], ['a', 'b', 'c'], ['a', 'b', 'c'],
['fo', 'bar'], ['man', 'o'], ['verylongvariablename'],
['verylongvariablename']]

vararg_names = [None, None, None, None, 'baz', 'men', None, None]
vararg_names = [None, None, None, 'baz', 'men', None, None]

kw_wc_names = [None, None, None, 'kwargs', None, 'oo', None, None]
kw_wc_names = [None, None, None, None, 'oo', None, None]

pos_arguments = [[], ['a', 'b', 'c'], [], ['a', 'b'], ['fo', 'bar'],
pos_arguments = [[], ['a', 'b', 'c'], [], ['fo', 'bar'],
['man', 'o'], ['verylongvariablename'],
['verylongvariablename']]

kwarg_list = [{}, {}, {'a': 1, 'b': 'fo', 'c': 9}, {'c': 3}, {}, {}, {}, {}]
kwarg_list = [{}, {}, {'a': 1, 'b': 'fo', 'c': 9}, {}, {}, {}, {}]


class SomeClass(object):
Expand Down Expand Up @@ -172,22 +167,16 @@ def test_construct_arguments_with_varargs_doesnt_raise():

def test_construct_arguments_with_kwargswildcard_doesnt_raise():
kwargs = {'zimbabwe': 23}
Signature(FunCTIonWithCAPItals).construct_arguments(
[1, 2, 3], kwargs, {})
Signature(__double_underscore__).construct_arguments([1, 2], kwargs, {})


def test_construct_arguments_with_expected_kwargs_does_not_raise():
s = Signature(complex_function_name)
s.construct_arguments([], {'a': 4, 'b': 3, 'c': 2}, {})
s = Signature(FunCTIonWithCAPItals)
s.construct_arguments([1, 2], {'c': 5}, {})


def test_construct_arguments_with_kwargs_for_posargs_does_not_raise():
Signature(bariza).construct_arguments([], {'a': 4, 'b': 3, 'c': 2}, {})
s = Signature(FunCTIonWithCAPItals)
s.construct_arguments([], {'a': 4, 'b': 3, 'c': 2, 'd': 6}, {})


def test_construct_arguments_with_duplicate_args_raises_typeerror():
Expand All @@ -200,10 +189,6 @@ def test_construct_arguments_with_duplicate_args_raises_typeerror():
s = Signature(complex_function_name)
s.construct_arguments([1], {'a': 4}, {})
assert multiple_values.match(excinfo.value.args[0])
with pytest.raises(TypeError) as excinfo:
s = Signature(FunCTIonWithCAPItals)
s.construct_arguments([1, 2, 3], {'c': 6}, {})
assert multiple_values.match(excinfo.value.args[0])


def test_construct_arguments_without_duplicates_passes():
Expand All @@ -213,9 +198,6 @@ def test_construct_arguments_without_duplicates_passes():
s = Signature(complex_function_name)
s.construct_arguments([1], {'b': 4}, {})

s = Signature(FunCTIonWithCAPItals)
s.construct_arguments([], {'a': 6, 'b': 6, 'c': 6}, {})


def test_construct_arguments_without_options_returns_same_args_kwargs():
s = Signature(foo)
Expand Down Expand Up @@ -318,7 +300,6 @@ def test_construct_arguments_for_bound_method():
@pytest.mark.parametrize('func,expected', [
(foo, "foo()"),
(bariza, "bariza(a, b, c)"),
(FunCTIonWithCAPItals, "FunCTIonWithCAPItals(a, b, c=3, **kwargs)"),
(_name_with_underscore_, "_name_with_underscore_(fo, bar, *baz)"),
(__double_underscore__, "__double_underscore__(man, o, *men, **oo)"),
(old_name, "old_name(verylongvariablename)"),
Expand Down
48 changes: 40 additions & 8 deletions tests/test_config/test_signature_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,30 @@ def complex_function_name(a: int = 5, b: str = 'fo', c: float = 9):
return a, b, c


# noinspection PyPep8Naming
def FunCTIonWithCAPItals(a, b, c=3, **kwargs):
return a, b, c, kwargs


def kwonly_args(a, *, b, c=10):
return b


functions = [foo, bariza, complex_function_name, kwonly_args]
functions = [foo, bariza, complex_function_name, FunCTIonWithCAPItals, kwonly_args]

ids = ['foo', 'bariza', 'complex_function_name', 'kwonly_args']
ids = ['foo', 'bariza', 'complex_function_name', 'FunCTIonWithCAPItals', 'kwonly_args']

names = ['foo', 'bariza', 'complex_function_name', 'kwonly_args']
names = ['foo', 'bariza', 'complex_function_name', 'FunCTIonWithCAPItals', 'kwonly_args']

arguments = [[], ['a', 'b', 'c'], ['a', 'b', 'c'], ['a', 'b', 'c']]
arguments = [[], ['a', 'b', 'c'], ['a', 'b', 'c'], ['a', 'b', 'c'], ['a', 'b', 'c']]

vararg_names = [None, None, None, None]
vararg_names = [None, None, None, None, None]

kw_wc_names = [None, None, None, None]
kw_wc_names = [None, None, None, 'kwargs', None]

pos_arguments = [[], ['a', 'b', 'c'], [], ['a']]
pos_arguments = [[], ['a', 'b', 'c'], [], ['a', 'b'], ['a']]

kwarg_list = [{}, {}, {'a': 5, 'b': 'fo', 'c': 9}, {'c': 10}]
kwarg_list = [{}, {}, {'a': 5, 'b': 'fo', 'c': 9}, {'c': 3}, {'c': 10}]


class SomeClass(object):
Expand Down Expand Up @@ -123,6 +128,25 @@ def test_construct_arguments_with_unexpected_args_raises_typeerror(func, args):
assert unexpected.match(excinfo.value.args[0])


def test_construct_arguments_with_kwargswildcard_doesnt_raise():
kwargs = {'zimbabwe': 23}
Signature(FunCTIonWithCAPItals).construct_arguments(
[1, 2, 3], kwargs, {})


def test_construct_arguments_with_expected_kwargs_does_not_raise():
s = Signature(complex_function_name)
s.construct_arguments([], {'a': 4, 'b': 3, 'c': 2}, {})
s = Signature(FunCTIonWithCAPItals)
s.construct_arguments([1, 2], {'c': 5}, {})


def test_construct_arguments_with_kwargs_for_posargs_does_not_raise():
Signature(bariza).construct_arguments([], {'a': 4, 'b': 3, 'c': 2}, {})
s = Signature(FunCTIonWithCAPItals)
s.construct_arguments([], {'a': 4, 'b': 3, 'c': 2, 'd': 6}, {})


def test_construct_arguments_with_duplicate_args_raises_typeerror():
multiple_values = re.compile(".*multiple values.*")
with pytest.raises(TypeError) as excinfo:
Expand All @@ -133,6 +157,10 @@ def test_construct_arguments_with_duplicate_args_raises_typeerror():
s = Signature(complex_function_name)
s.construct_arguments([1], {'a': 4}, {})
assert multiple_values.match(excinfo.value.args[0])
with pytest.raises(TypeError) as excinfo:
s = Signature(FunCTIonWithCAPItals)
s.construct_arguments([1, 2, 3], {'c': 6}, {})
assert multiple_values.match(excinfo.value.args[0])


def test_construct_arguments_without_duplicates_passes():
Expand All @@ -142,6 +170,9 @@ def test_construct_arguments_without_duplicates_passes():
s = Signature(complex_function_name)
s.construct_arguments([1], {'b': 4}, {})

s = Signature(FunCTIonWithCAPItals)
s.construct_arguments([], {'a': 6, 'b': 6, 'c': 6}, {})


def test_construct_arguments_without_options_returns_same_args_kwargs():
s = Signature(foo)
Expand Down Expand Up @@ -234,6 +265,7 @@ def test_construct_arguments_for_bound_method():
@pytest.mark.parametrize('func,expected', [
(foo, "foo()"),
(bariza, "bariza(a, b, c)"),
(FunCTIonWithCAPItals, "FunCTIonWithCAPItals(a, b, c=3, **kwargs)")
])
def test_unicode_(func, expected):
assert Signature(func).__unicode__() == expected
Expand Down