Skip to contentSkip to conversation

tc-testing: better check if thing is list

PATCH Applied Brenda J. Butler 3 participants 3 messages Oct 31, 2017 – Nov 1, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tc-testing: better check if thing is list

Check if tcase[k] is an instance of a list (is or is derived from list) instead of checking if it is a list.

This will be useful if the data structures change to be something that implements list, instead of being an actual list. In that case, this code will not have to change.

---
 tools/testing/selftests/tc-testing/tdc_helper.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/tc-testing/tdc_helper.py +1 -1
index c3254f861fb2..b4fbb0ce0cbe 100644
@@ -57,7 +57,7 @@ def print_sll(items):
 def print_test_case(tcase):
     """ Pretty-printing of a given test case. """
     for k in tcase.keys():
-        if (type(tcase[k]) == list):
+        if (isinstance(tcase[k], list)):
             print(k + ":")
             print_list(tcase[k])
         else:
Signature · 1 line
2.15.0.rc0
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Brenda J. Butler

Check if tcase[k] is an instance of a list (is or is derived from list) instead of checking if it is a list.

This will be useful if the data structures change to be something that implements list, instead of being an actual list. In that case, this code will not have to change.

maintainer Applied
#2 lore raw
In reply to Brenda J. Butler

From: "Brenda J. Butler" <[email protected]>
Date: Tue, 31 Oct 2017 14:28:35 -0400

Quoted 8 lines

Check if tcase[k] is an instance of a list (is or is derived from list) instead of checking if it is a list.

This will be useful if the data structures change to be something that implements list, instead of being an actual list. In that case, this code will not have to change.

Applied.