diff options
author | bdista <bdista@users.noreply.github.com> | 2021-05-01 00:48:47 +0200 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2022-02-19 07:36:03 -0800 |
commit | 5bc59bdc5ea2a2b9aa5a56c5af8a2abbc2a91453 (patch) | |
tree | 67f229b6abbe0454eece4fe19b42f18d72c201eb /tests/test_arguments.py | |
parent | 1c42559832d31e9411766673f472c0893eacf9ba (diff) | |
download | click-5bc59bdc5ea2a2b9aa5a56c5af8a2abbc2a91453.tar.gz |
replace for loop with parametrize
Diffstat (limited to 'tests/test_arguments.py')
-rw-r--r-- | tests/test_arguments.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/tests/test_arguments.py b/tests/test_arguments.py index b4719d6..735df4b 100644 --- a/tests/test_arguments.py +++ b/tests/test_arguments.py @@ -41,25 +41,25 @@ def test_nargs_tup(runner): assert result.output.splitlines() == ["name=peter", "point=1/2"] -def test_nargs_tup_composite(runner): - variations = [ +@pytest.mark.parametrize( + "opts", + [ dict(type=(str, int)), dict(type=click.Tuple([str, int])), dict(nargs=2, type=click.Tuple([str, int])), dict(nargs=2, type=(str, int)), - ] - - for opts in variations: - - @click.command() - @click.argument("item", **opts) - def copy(item): - name, id = item - click.echo(f"name={name} id={id:d}") - - result = runner.invoke(copy, ["peter", "1"]) - assert not result.exception - assert result.output.splitlines() == ["name=peter id=1"] + ], +) +def test_nargs_tup_composite(runner, opts): + @click.command() + @click.argument("item", **opts) + def copy(item): + name, id = item + click.echo(f"name={name} id={id:d}") + + result = runner.invoke(copy, ["peter", "1"]) + assert result.exception is None + assert result.output.splitlines() == ["name=peter id=1"] def test_nargs_err(runner): |