summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshish Pant <ashish12pant@gmail.com>2019-10-17 04:45:28 +0530
committerAshish Pant <ashish12pant@gmail.com>2019-10-17 09:17:03 +0530
commit287d692409705eac36a7ced3d56a802d99c9fcaf (patch)
treeb4e20a33e44bbd9fcee1c6b643e7d93c089dd6a4
parente75bbefa0e41995051d625aad3bfb5273ff3dc20 (diff)
tests: Add step api in topojson
Signed-off-by: Ashish Pant <ashish12pant@gmail.com> Print messages with a step number to log from test case
-rw-r--r--tests/topotests/lib/common_config.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py
index c413bf45c7..efef0395ac 100644
--- a/tests/topotests/lib/common_config.py
+++ b/tests/topotests/lib/common_config.py
@@ -617,7 +617,7 @@ def write_test_header(tc_name):
""" Display message at beginning of test case"""
count = 20
logger.info("*"*(len(tc_name)+count))
- logger.info("START -> Testcase : %s" % tc_name)
+ step("START -> Testcase : %s" % tc_name, reset=True)
logger.info("*"*(len(tc_name)+count))
@@ -732,6 +732,31 @@ def retry(attempts=3, wait=2, return_is_str=True, initial_wait=0):
return _retry
+class Stepper:
+ """
+ Prints step number for the test case step being executed
+ """
+ count = 1
+
+ def __call__(self, msg, reset):
+ if reset:
+ Stepper.count = 1
+ logger.info(msg)
+ else:
+ logger.info("STEP %s: '%s'", Stepper.count, msg)
+ Stepper.count += 1
+
+
+def step(msg, reset=False):
+ """
+ Call Stepper to print test steps. Need to reset at the beginning of test.
+ * ` msg` : Step message body.
+ * `reset` : Reset step count to 1 when set to True.
+ """
+ _step = Stepper()
+ _step(msg, reset)
+
+
#############################################
# These APIs, will used by testcase
#############################################