mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-09 06:23:52 +08:00
fix: RecursionError caused by checking root dir incorrectly on Windows
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
**Fixed**
|
**Fixed**
|
||||||
|
|
||||||
- fix #835: UnicodeDecodeError when loading json schema files
|
- fix #835: UnicodeDecodeError when loading json schema files
|
||||||
|
- fix: RecursionError caused by checking root dir incorrectly on Windows
|
||||||
|
|
||||||
## 2.5.3 (2020-01-03)
|
## 2.5.3 (2020-01-03)
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ project_working_directory = None
|
|||||||
|
|
||||||
def locate_file(start_path, file_name):
|
def locate_file(start_path, file_name):
|
||||||
""" locate filename and return absolute file path.
|
""" locate filename and return absolute file path.
|
||||||
searching will be recursive upward until current working directory.
|
searching will be recursive upward until current working directory or system root dir.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
file_name (str): target locate file name
|
file_name (str): target locate file name
|
||||||
@@ -33,11 +33,18 @@ def locate_file(start_path, file_name):
|
|||||||
return os.path.abspath(file_path)
|
return os.path.abspath(file_path)
|
||||||
|
|
||||||
# current working directory
|
# current working directory
|
||||||
if os.path.abspath(start_dir_path) in [os.getcwd(), os.path.abspath(os.sep)]:
|
if os.path.abspath(start_dir_path) == os.getcwd():
|
||||||
|
raise exceptions.FileNotFound("{} not found in {}".format(file_name, start_path))
|
||||||
|
|
||||||
|
# system root dir
|
||||||
|
# Windows, e.g. 'E:\\'
|
||||||
|
# Linux/Darwin, '/'
|
||||||
|
parent_dir = os.path.dirname(start_dir_path)
|
||||||
|
if parent_dir == start_dir_path:
|
||||||
raise exceptions.FileNotFound("{} not found in {}".format(file_name, start_path))
|
raise exceptions.FileNotFound("{} not found in {}".format(file_name, start_path))
|
||||||
|
|
||||||
# locate recursive upward
|
# locate recursive upward
|
||||||
return locate_file(os.path.dirname(start_dir_path), file_name)
|
return locate_file(parent_dir, file_name)
|
||||||
|
|
||||||
|
|
||||||
def locate_debugtalk_py(start_path):
|
def locate_debugtalk_py(start_path):
|
||||||
|
|||||||
Reference in New Issue
Block a user