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
This commit is contained in:
Leo Hemsted
2016-07-18 12:02:27 +01:00
parent 67542280f5
commit a355f3e544

View File

@@ -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)