Skip to content

Commit

Permalink
fix: RecursionError caused by checking root dir incorrectly on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
debugtalk committed Jan 3, 2020
1 parent db4fcbb commit 69e9fba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
**Fixed**

- fix #835: UnicodeDecodeError when loading json schema files
- fix: RecursionError caused by checking root dir incorrectly on Windows

## 2.5.3 (2020-01-03)

Expand Down
13 changes: 10 additions & 3 deletions httprunner/loader/locate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def locate_file(start_path, file_name):
""" 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:
file_name (str): target locate file name
Expand All @@ -33,11 +33,18 @@ def locate_file(start_path, file_name):
return os.path.abspath(file_path)

# 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))

# 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):
Expand Down

0 comments on commit 69e9fba

Please sign in to comment.