mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-09 03:21:51 +00:00
test/py: Provide custom IDs when parametrizing tests
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> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
a2ec560647
commit
d20e5e976f
3 changed files with 13 additions and 1 deletions
|
@ -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.
|
||||
vals = subconfig.get(fn + 's', [])
|
||||
metafunc.parametrize(fn, vals)
|
||||
def fixture_id(index, val):
|
||||
try:
|
||||
return val["fixture_id"]
|
||||
except:
|
||||
return fn + str(index)
|
||||
ids = [fixture_id(index, val) for (index, val) in enumerate(vals)]
|
||||
metafunc.parametrize(fn, vals, ids=ids)
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def u_boot_console(request):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue