mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 03:24:45 +01:00
selftests: tc-testing: fix list_categories() crash on list type
list_categories() builds a set directly from the 'category' field of each test case. Since 'category' is a list, set(map(...)) attempts to insert lists into a set, which raises: TypeError: unhashable type: 'list' Flatten category lists and collect unique category names using set.update() instead. Signed-off-by: Naveen Anandhan <mr.navi8680@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
46d0d6f50d
commit
fbdfa8da05
1 changed files with 7 additions and 3 deletions
|
|
@ -38,10 +38,14 @@ def list_test_cases(testlist):
|
|||
|
||||
|
||||
def list_categories(testlist):
|
||||
""" Show all categories that are present in a test case file. """
|
||||
categories = set(map(lambda x: x['category'], testlist))
|
||||
"""Show all unique categories present in the test cases."""
|
||||
categories = set()
|
||||
for t in testlist:
|
||||
if 'category' in t:
|
||||
categories.update(t['category'])
|
||||
|
||||
print("Available categories:")
|
||||
print(", ".join(str(s) for s in categories))
|
||||
print(", ".join(sorted(categories)))
|
||||
print("")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue