[PATCH net-next] tc-testing: better check if thing is list

Subsystems: kernel selftest framework, the rest

STALE3206d

3 messages, 3 authors, 2017-11-01 · open the first message on its own page

[PATCH net-next] tc-testing: better check if thing is list

From: Brenda J. Butler <hidden>
Date: 2017-10-31 18:28:41

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.

Signed-off-by: Brenda J. Butler <redacted>
---
 tools/testing/selftests/tc-testing/tdc_helper.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/tc-testing/tdc_helper.py b/tools/testing/selftests/tc-testing/tdc_helper.py
index c3254f861fb2..b4fbb0ce0cbe 100644
--- a/tools/testing/selftests/tc-testing/tdc_helper.py
+++ b/tools/testing/selftests/tc-testing/tdc_helper.py
@@ -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:
-- 
2.15.0.rc0

Re: [PATCH net-next] tc-testing: better check if thing is list

From: Lucas Bates <hidden>
Date: 2017-10-31 18:43:50

On Tue, Oct 31, 2017 at 2:28 PM, Brenda J. Butler [off-list ref] wrote:
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.

Signed-off-by: Brenda J. Butler <redacted>
Acked-by: Lucas Bates <redacted>

Re: [PATCH net-next] tc-testing: better check if thing is list

From: David Miller <davem@davemloft.net>
Date: 2017-11-01 02:06:40

From: "Brenda J. Butler" <redacted>
Date: Tue, 31 Oct 2017 14:28:35 -0400
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.

Signed-off-by: Brenda J. Butler <redacted>
Applied.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help