diff --git a/httprunner/cli.py b/httprunner/cli.py index 8258ba4f..5e8a5576 100644 --- a/httprunner/cli.py +++ b/httprunner/cli.py @@ -7,7 +7,7 @@ from sentry_sdk import capture_exception from httprunner import __description__, __version__ from httprunner.api import HttpRunner 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.report import gen_html_report from httprunner.utils import (create_scaffold, get_python2_retire_msg, @@ -73,7 +73,7 @@ def main(): sys.exit(0) if args.validate: - validate_json_file(args.validate) + validate_test_file(args.validate) sys.exit(0) if args.prettify: prettify_json_file(args.prettify) diff --git a/httprunner/loader/__init__.py b/httprunner/loader/__init__.py index 46e18ad5..79fc4a3c 100644 --- a/httprunner/loader/__init__.py +++ b/httprunner/loader/__init__.py @@ -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.load import load_csv_file, load_builtin_functions 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__ = [ "is_testcase_path", "is_testcases", - "validate_json_file", + "validate_test_file", "get_pwd", "load_csv_file", "load_builtin_functions", diff --git a/httprunner/loader/check.py b/httprunner/loader/check.py index 9654709b..4e5943b3 100644 --- a/httprunner/loader/check.py +++ b/httprunner/loader/check.py @@ -149,17 +149,17 @@ def check_testcase_format(file_path, content): raise exceptions.FileFormatError(err_msg) -def validate_json_file(file_list): +def validate_test_file(file_list): """ validate JSON testcase format """ - for json_file in set(file_list): - if not json_file.endswith(".json"): - logger.log_warning("Only JSON file format can be validated, skip: {}".format(json_file)) + for test_file in set(file_list): + if not test_file.endswith(".json"): + logger.log_warning("Only JSON file format can be validated, skip: {}".format(test_file)) 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: json.load(stream) except ValueError as e: