mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-17 02:47:36 +08:00
remove cli --pretty
This commit is contained in:
@@ -5,12 +5,10 @@ import sys
|
||||
import sentry_sdk
|
||||
from loguru import logger
|
||||
|
||||
from httprunner import __description__, __version__, exceptions
|
||||
from httprunner import __description__, __version__
|
||||
from httprunner.api import HttpRunner
|
||||
from httprunner.loader import load_cases
|
||||
from httprunner.report import gen_html_report
|
||||
from httprunner.utils import (create_scaffold,
|
||||
prettify_json_file, init_sentry_sdk)
|
||||
from httprunner.utils import create_scaffold, init_sentry_sdk
|
||||
|
||||
init_sentry_sdk()
|
||||
|
||||
@@ -52,9 +50,6 @@ def main():
|
||||
parser.add_argument(
|
||||
'--startproject',
|
||||
help="Specify new project name.")
|
||||
parser.add_argument(
|
||||
'--prettify', nargs='*',
|
||||
help="Prettify JSON testcase format.")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -67,10 +62,6 @@ def main():
|
||||
print(f"{__version__}")
|
||||
sys.exit(0)
|
||||
|
||||
if args.prettify:
|
||||
prettify_json_file(args.prettify)
|
||||
sys.exit(0)
|
||||
|
||||
project_name = args.startproject
|
||||
if project_name:
|
||||
create_scaffold(project_name)
|
||||
|
||||
@@ -514,33 +514,6 @@ def gen_cartesian_product(*args):
|
||||
return product_list
|
||||
|
||||
|
||||
def prettify_json_file(file_list):
|
||||
""" prettify JSON testcase format
|
||||
"""
|
||||
for json_file in set(file_list):
|
||||
if not json_file.endswith(".json"):
|
||||
logger.warning(f"Only JSON file format can be prettified, skip: {json_file}")
|
||||
continue
|
||||
|
||||
logger.info(f"Start to prettify JSON file: {json_file}")
|
||||
|
||||
dir_path = os.path.dirname(json_file)
|
||||
file_name, file_suffix = os.path.splitext(os.path.basename(json_file))
|
||||
outfile = os.path.join(dir_path, f"{file_name}.pretty.json")
|
||||
|
||||
with io.open(json_file, 'r', encoding='utf-8') as stream:
|
||||
try:
|
||||
obj = json.load(stream)
|
||||
except ValueError as e:
|
||||
raise SystemExit(e)
|
||||
|
||||
with io.open(outfile, 'w', encoding='utf-8') as out:
|
||||
json.dump(obj, out, indent=4, separators=(',', ': '))
|
||||
out.write('\n')
|
||||
|
||||
print(f"success: {outfile}")
|
||||
|
||||
|
||||
def omit_long_data(body, omit_len=512):
|
||||
""" omit too long str/bytes
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user