diff options
author | imarom <imarom@cisco.com> | 2016-01-17 04:28:55 -0500 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2016-01-21 10:11:54 -0500 |
commit | 11d328d3e40b04540489eec83ac484d5b06254bb (patch) | |
tree | 63e512cd9d6a6911eddecc38dd9b17374e53bff3 /scripts/automation/trex_control_plane/common | |
parent | 9c9173a53fc09d08cf39e614dffa24f4e21a69e9 (diff) |
draft of test API for stateless
Diffstat (limited to 'scripts/automation/trex_control_plane/common')
-rw-r--r-- | scripts/automation/trex_control_plane/common/trex_types.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/scripts/automation/trex_control_plane/common/trex_types.py b/scripts/automation/trex_control_plane/common/trex_types.py index 7c3f04c5..21deffd2 100644 --- a/scripts/automation/trex_control_plane/common/trex_types.py +++ b/scripts/automation/trex_control_plane/common/trex_types.py @@ -21,6 +21,9 @@ class RC(): tuple_rc = namedtuple('RC', ['rc', 'data']) self.rc_list.append(tuple_rc(rc, data)) + def __nonzero__ (self): + return self.good() + def add (self, rc): self.rc_list += rc.rc_list @@ -38,27 +41,30 @@ class RC(): e = [x.data if not x.rc else "" for x in self.rc_list] return (e if len(e) > 1 else e[0]) - def annotate (self, desc = None, show_status = True): + def __str__ (self): + return str(self.data()) if self else str(self.err()) + + def annotate (self, log_func, desc = None, show_status = True): if desc: - print format_text('\n{:<60}'.format(desc), 'bold'), + log_func(format_text('\n{:<60}'.format(desc), 'bold'), newline = False) else: - print "" + log_func("") if self.bad(): # print all the errors print "" for x in self.rc_list: if not x.rc: - print format_text("\n{0}".format(x.data), 'bold') + log_func(format_text("\n{0}".format(x.data), 'bold')) print "" if show_status: - print format_text("[FAILED]\n", 'red', 'bold') + log_func(format_text("[FAILED]\n", 'red', 'bold')) else: if show_status: - print format_text("[SUCCESS]\n", 'green', 'bold') + log_func(format_text("[SUCCESS]\n", 'green', 'bold')) def RC_OK(data = ""): |