mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
change: function name, validate_json_file => validate_test_file
This commit is contained in:
+2
-2
@@ -7,7 +7,7 @@ from sentry_sdk import capture_exception
|
|||||||
from httprunner import __description__, __version__
|
from httprunner import __description__, __version__
|
||||||
from httprunner.api import HttpRunner
|
from httprunner.api import HttpRunner
|
||||||
from httprunner.compat import is_py2
|
from httprunner.compat import is_py2
|
||||||
from httprunner.loader import validate_json_file
|
from httprunner.loader import validate_test_file
|
||||||
from httprunner.logger import color_print
|
from httprunner.logger import color_print
|
||||||
from httprunner.report import gen_html_report
|
from httprunner.report import gen_html_report
|
||||||
from httprunner.utils import (create_scaffold, get_python2_retire_msg,
|
from httprunner.utils import (create_scaffold, get_python2_retire_msg,
|
||||||
@@ -73,7 +73,7 @@ def main():
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if args.validate:
|
if args.validate:
|
||||||
validate_json_file(args.validate)
|
validate_test_file(args.validate)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
if args.prettify:
|
if args.prettify:
|
||||||
prettify_json_file(args.prettify)
|
prettify_json_file(args.prettify)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ HttpRunner loader
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from httprunner.loader.check import is_testcase_path, is_testcases, validate_json_file
|
from httprunner.loader.check import is_testcase_path, is_testcases, validate_test_file
|
||||||
from httprunner.loader.locate import get_project_working_directory as get_pwd
|
from httprunner.loader.locate import get_project_working_directory as get_pwd
|
||||||
from httprunner.loader.load import load_csv_file, load_builtin_functions
|
from httprunner.loader.load import load_csv_file, load_builtin_functions
|
||||||
from httprunner.loader.buildup import load_cases, load_project_data
|
from httprunner.loader.buildup import load_cases, load_project_data
|
||||||
@@ -16,7 +16,7 @@ from httprunner.loader.buildup import load_cases, load_project_data
|
|||||||
__all__ = [
|
__all__ = [
|
||||||
"is_testcase_path",
|
"is_testcase_path",
|
||||||
"is_testcases",
|
"is_testcases",
|
||||||
"validate_json_file",
|
"validate_test_file",
|
||||||
"get_pwd",
|
"get_pwd",
|
||||||
"load_csv_file",
|
"load_csv_file",
|
||||||
"load_builtin_functions",
|
"load_builtin_functions",
|
||||||
|
|||||||
@@ -149,17 +149,17 @@ def check_testcase_format(file_path, content):
|
|||||||
raise exceptions.FileFormatError(err_msg)
|
raise exceptions.FileFormatError(err_msg)
|
||||||
|
|
||||||
|
|
||||||
def validate_json_file(file_list):
|
def validate_test_file(file_list):
|
||||||
""" validate JSON testcase format
|
""" validate JSON testcase format
|
||||||
"""
|
"""
|
||||||
for json_file in set(file_list):
|
for test_file in set(file_list):
|
||||||
if not json_file.endswith(".json"):
|
if not test_file.endswith(".json"):
|
||||||
logger.log_warning("Only JSON file format can be validated, skip: {}".format(json_file))
|
logger.log_warning("Only JSON file format can be validated, skip: {}".format(test_file))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
logger.color_print("Start to validate JSON file: {}".format(json_file), "GREEN")
|
logger.color_print("Start to validate JSON file: {}".format(test_file), "GREEN")
|
||||||
|
|
||||||
with io.open(json_file) as stream:
|
with io.open(test_file) as stream:
|
||||||
try:
|
try:
|
||||||
json.load(stream)
|
json.load(stream)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user