Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Naveen Anandhan and committed by
David S. Miller
fbdfa8da 46d0d6f5

+7 -3
+7 -3
tools/testing/selftests/tc-testing/tdc_helper.py
··· 38 38 39 39 40 40 def list_categories(testlist): 41 - """ Show all categories that are present in a test case file. """ 42 - categories = set(map(lambda x: x['category'], testlist)) 41 + """Show all unique categories present in the test cases.""" 42 + categories = set() 43 + for t in testlist: 44 + if 'category' in t: 45 + categories.update(t['category']) 46 + 43 47 print("Available categories:") 44 - print(", ".join(str(s) for s in categories)) 48 + print(", ".join(sorted(categories))) 45 49 print("") 46 50 47 51