test suite reviews and discussions
 help / color / mirror / Atom feed
From: Marvin Liu <yong.liu@intel.com>
To: dts@dpdk.org
Cc: Marvin Liu <yong.liu@intel.com>
Subject: [dts] [PATCH 6/9] framework test_result: add class to handle result
Date: Thu,  4 Aug 2016 13:38:19 +0800	[thread overview]
Message-ID: <1470289102-12677-7-git-send-email-yong.liu@intel.com> (raw)
In-Reply-To: <1470289102-12677-1-git-send-email-yong.liu@intel.com>

Each suite will own itselves table result and remove table handle
function in dts module.

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/framework/test_result.py b/framework/test_result.py
index 9cef34c..e5a2b4e 100644
--- a/framework/test_result.py
+++ b/framework/test_result.py
@@ -32,6 +32,7 @@
 """
 Generic result container and reporters
 """
+import texttable    # text format
 
 
 class Result(object):
@@ -151,13 +152,16 @@ class Result(object):
         self.__test_result = result
         self.__message = message
 
+    def copy_suite(self, suite_result):
+        self.__current_suites()[self.__test_suite + 1] = suite_result.__current_cases()
+
     def test_case_passed(self):
         """
         Set last test case added as PASSED
         """
         self.__set_test_case_result(result='PASSED', message='')
 
-    def test_case_skip(self,message):
+    def test_case_skip(self, message):
         """
         set last test case add as N/A
         """
@@ -290,3 +294,60 @@ class Result(object):
     message = property(__get_message)
     nic = property(__get_nic, __set_nic)
     internals = property(__get_internals)
+
+
+class ResultTable(object):
+
+    def __init__(self, header):
+        """
+        Add the title of result table.
+        Usage:
+        rt = ResultTable(header)
+        rt.add_row(row)
+        rt.table_print()
+        """
+        self.results_table_rows = []
+        self.results_table_rows.append([])
+        self.table = texttable.Texttable(max_width=150)
+        self.results_table_header = header
+        self.logger = None
+        self.rst = None
+
+    def set_rst(self, rst):
+        self.rst = rst
+
+    def set_logger(self, logger):
+        self.logger = logger
+
+    def add_row(self, row):
+        """
+        Add one row to result table.
+        """
+        self.results_table_rows.append(row)
+
+    def table_print(self):
+        """
+        Show off result table.
+        """
+        self.table.add_rows(self.results_table_rows)
+        self.table.header(self.results_table_header)
+
+        alignments = []
+        # all header align to left
+        for _ in self.results_table_header:
+            alignments.append("l")
+        self.table.set_cols_align(alignments)
+
+        out = self.table.draw()
+        if self.rst:
+            self.rst.write_text('\n' + out + '\n\n')
+        if self.logger:
+            self.logger.info('\n' + out)
+
+###############################################################################
+###############################################################################
+if __name__ == "__main__":
+    rt = ResultTable(header=['name', 'age'])
+    rt.add_row(['Jane', '30'])
+    rt.add_row(['Mark', '32'])
+    rt.table_print()
-- 
1.9.3

  parent reply	other threads:[~2016-08-04  5:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04  5:38 [dts] [PATCH 0/9] optimize overall execution process Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 1/9] framework dts: optimize " Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 2/9] framework config: add concept for dut board Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 3/9] framework dut: remove dependency on dts module Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 4/9] framework rst: add class to handle RST report Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 5/9] framework settings: support global setting load and save Marvin Liu
2016-08-04  5:38 ` Marvin Liu [this message]
2016-08-04  5:38 ` [dts] [PATCH 7/9] framework test_case: add test case handle logic Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 8/9] framework utils: move shared function from dts module Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 9/9] tests: remove dependencies of " Marvin Liu
2016-08-04  6:07 ` [dts] [PATCH 0/9] optimize overall execution process Liu, Yong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1470289102-12677-7-git-send-email-yong.liu@intel.com \
    --to=yong.liu@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).