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

@parameterized.expand fails with type hinting #126

Open
tomepel opened this issue Jul 19, 2021 · 0 comments
Open

@parameterized.expand fails with type hinting #126

tomepel opened this issue Jul 19, 2021 · 0 comments

Comments

@tomepel
Copy link

tomepel commented Jul 19, 2021

@parameterized.expand is not compatible with type hinting.

Minimal working example (python 3.8, unittest)

def foo_bar_provider() -> List[List]:
    return [['foo'], ['bar']]

  @parameterized.expand(foo_bar_provider)
    def test_foo_bar(self, provider: str):

Gives the following error

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File <LOCAL>
  File <LOCAL>
    def test_foo_bar(self, provider: str):
  File "/usr/local/lib/python3.8/dist-packages/parameterized/parameterized.py", line 383, in parameterized_expand_wrapper
    frame_locals[name].__doc__ = doc_func(f, num, p)
  File "/usr/local/lib/python3.8/dist-packages/parameterized/parameterized.py", line 189, in default_doc_func
    all_args_with_values = parameterized_argument_value_pairs(func, p)
  File "/usr/local/lib/python3.8/dist-packages/parameterized/parameterized.py", line 136, in parameterized_argument_value_pairs
    argspec = inspect.getargspec(func)
  File "/usr/lib/python3.8/inspect.py", line 1083, in getargspec
    raise ValueError("Function has keyword-only parameters or annotations"
ValueError: Function has keyword-only parameters or annotations, use inspect.signature() API which can support them

While

def foo_bar_provider() -> List[List]:
    return [['foo'], ['bar']]

  @parameterized.expand(foo_bar_provider)
    def test_foo_bar(self, provider):

works as intended

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant