Skip to content

Commit

Permalink
make sure paths found by find_command are files
Browse files Browse the repository at this point in the history
  • Loading branch information
mgax committed Mar 14, 2011
1 parent b3423ad commit 0236a47
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pip/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def find_command(cmd, paths=None, pathext=None):
for ext in pathext:
# then including the extension
cmd_path_ext = cmd_path + ext
if os.path.exists(cmd_path_ext):
if os.path.isfile(cmd_path_ext):
return cmd_path_ext
if os.path.exists(cmd_path):
if os.path.isfile(cmd_path):
return cmd_path
return None

Expand Down
15 changes: 15 additions & 0 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,18 @@ def test_install_package_which_contains_dev_in_name():
egg_info_folder = env.site_packages/'django_devserver-0.0.4-py%s.egg-info' % pyversion
assert devserver_folder in result.files_created, str(result.stdout)
assert egg_info_folder in result.files_created, str(result)

def test_find_command_folder_in_path():
"""
If a folder named e.g. 'git' is in PATH, and find_command is looking for
the 'git' executable, it should not match the folder, but rather keep
looking.
"""
env = reset_env()
mkdir('path_one'); path_one = env.scratch_path/'path_one'
mkdir(path_one/'foo')
mkdir('path_two'); path_two = env.scratch_path/'path_two'
write_file(path_two/'foo', '# nothing')
from pip.util import find_command
found_path = find_command('foo', map(str, [path_one, path_two]))
assert found_path == path_two/'foo'

0 comments on commit 0236a47

Please sign in to comment.