[U-Boot] [PATCH] test/py: Provide custom IDs when parametrizing tests

Simon Glass
2016-01-29T04:02:13Z

On 26 January 2016 at 16:18, Stephen Warren <swarren@wwwdotorg.org> wrote:
> On 01/26/2016 04:08 PM, Simon Glass wrote:
>>
>> Hi Stephen,
>>
>> On 26 January 2016 at 15:26, Stephen Warren <swarren@wwwdotorg.org> wrote:
>>>
>>> From: Stephen Warren <swarren@nvidia.com>
>>>
>>> When pytest generates the name for parametrized tests, simple parameter
>>> values (ints, strings) get used directly, but more complex values such
>>> as dicts are not handled. This yields test names such as:
>>>
>>> dfu[env__usb_dev_port0-env__dfu_config0]
>>> dfu[env__usb_dev_port0-env__dfu_config1]
>>>
>>> Add some code to extract a custom fixture ID from the fixture values, so
>>> that we end up with meaningful names such as:
>>>
>>> dfu[micro_b-emmc]
>>> dfu[devport2-ram]
>>>
>>> If the boardenv file doesn't define custom names, the code falls back to
>>> the old algorithm.
>>>
>>> Signed-off-by: Stephen Warren <swarren@nvidia.com>
>>> ---
>>> test/py/conftest.py | 8 +++++++-
>>> test/py/tests/test_dfu.py | 3 +++
>>> test/py/tests/test_ums.py | 3 +++
>>> 3 files changed, 13 insertions(+), 1 deletion(-)
>>
>>
>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>
>>> diff --git a/test/py/conftest.py b/test/py/conftest.py
>
>
>>> @@ -225,7 +225,13 @@ def pytest_generate_tests(metafunc):
>>> # ... otherwise, see if there's a key that contains a list
>>> of
>>> # values to use instead.
>>
>>
>> Is this function comment still accurate?
>
>
> Yes; that comment is referring to the list of values that the relevant test
> function iterates over, not the names/IDs of the values or anything like
> that.
>

Applied to u-boot-dm, thanks!