#96: refactor skip feature:

1, with skip keyword, skip current test unconditionally;
2, with skipIf keyword, you can skip current test with condition; condition evaluation can be defined in debugtalk.py function.
This commit is contained in:
httprunner
2018-02-08 15:59:17 +08:00
parent 5bbbdc1997
commit 9042e6e72f
6 changed files with 44 additions and 8 deletions

View File

@@ -1,4 +1,5 @@
import logging
from unittest.case import SkipTest
from httprunner import exception, response, testcase, utils
from httprunner.client import HttpSession
@@ -107,6 +108,12 @@ class Runner(object):
setup_actions = testcase_dict.get("setup", [])
teardown_actions = testcase_dict.get("teardown", [])
if "skipIf" in testcase_dict:
skip_if_condition = testcase_dict["skipIf"]
if self.context.exec_content_functions(skip_if_condition):
skip_reason = "{} evaluate to True".format(skip_if_condition)
raise SkipTest(skip_reason)
def setup_teardown(actions):
for action in actions:
self.context.exec_content_functions(action)