From a355f3e54480b0983d062a16ab18d108c2e78fae Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Mon, 18 Jul 2016 12:02:27 +0100 Subject: [PATCH] add idparametrize pytest decorator so you can specify test IDs in a reasonable dictionary syntax, which is useful when the parameters may not be immediately self-explanatory --- tests/conftest.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index bf8a68565..511cdf5fd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -68,3 +68,11 @@ def os_environ(request): def sqs_client_conn(request): boto3.setup_default_session(region_name='eu-west-1') return boto3.resource('sqs') + +def pytest_generate_tests(metafunc): + # Copied from https://gist.github.com/pfctdayelise/5719730 + idparametrize = getattr(metafunc.function, 'idparametrize', None) + if idparametrize: + argnames, testdata = idparametrize.args + ids, argvalues = zip(*sorted(testdata.items())) + metafunc.parametrize(argnames, argvalues, ids=ids)