From 5bc59bdc5ea2a2b9aa5a56c5af8a2abbc2a91453 Mon Sep 17 00:00:00 2001 From: bdista Date: Sat, 1 May 2021 00:48:47 +0200 Subject: replace for loop with parametrize --- tests/test_arguments.py | 30 +++++++++++++++--------------- 1 file 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): -- cgit v1.2.1