From 9ff3f943ab2c101120f1e6b474d6e5dc75ea9a37 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Mon, 15 Jun 2020 18:14:35 +0800 Subject: [PATCH] fix: FileExistsError when specified project name conflicts with existed file --- docs/CHANGELOG.md | 1 + httprunner/scaffold.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ec9d269a..f3e5444d 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -8,6 +8,7 @@ - fix: convert har to JSON format testcase - fix: missing ${var} handling in overriding config variables - fix: SyntaxError caused by quote in case of headers."Set-Cookie" +- fix: FileExistsError when specified project name conflicts with existed file ## 3.0.12 (2020-06-14) diff --git a/httprunner/scaffold.py b/httprunner/scaffold.py index 8f077c80..07d1f33a 100644 --- a/httprunner/scaffold.py +++ b/httprunner/scaffold.py @@ -19,6 +19,7 @@ def init_parser_scaffold(subparsers): def create_scaffold(project_name): """ create scaffold with specified project name. """ + def show_tree(prj_name): try: print(f"\n$ tree {prj_name} -a") @@ -29,10 +30,15 @@ def create_scaffold(project_name): if os.path.isdir(project_name): logger.warning( - f"Project {project_name} exists, please specify a new project name." + f"Project folder {project_name} exists, please specify a new project name." ) show_tree(project_name) return 1 + elif os.path.isfile(project_name): + logger.warning( + f"Project name {project_name} conflicts with existed file, please specify a new one." + ) + return 1 logger.info(f"Create new project: {project_name}") print(f"Project Root Dir: {os.path.join(os.getcwd(), project_name)}\n")