Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
3e73edd3
P
pip
项目概览
镜像
/
Python_Packaging_Authority
/
pip
12 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pip
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
3e73edd3
编写于
8月 04, 2019
作者:
P
Pradyun Gedam
提交者:
GitHub
8月 04, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6827 from cjerdonek/issue-6804-find-links-expansion
Fix "~" expansion in --find-links paths
上级
82dbcdae
56324a3f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
56 addition
and
13 deletion
+56
-13
news/6804.bugfix
news/6804.bugfix
+2
-0
src/pip/_internal/cli/cmdoptions.py
src/pip/_internal/cli/cmdoptions.py
+5
-3
tests/unit/test_cmdoptions.py
tests/unit/test_cmdoptions.py
+48
-9
tests/unit/test_unit_outdated.py
tests/unit/test_unit_outdated.py
+1
-1
未找到文件。
news/6804.bugfix
0 → 100644
浏览文件 @
3e73edd3
Fix a regression that caused ``~`` expansion not to occur in ``--find-links``
paths.
src/pip/_internal/cli/cmdoptions.py
浏览文件 @
3e73edd3
...
...
@@ -370,9 +370,11 @@ def make_search_scope(options, suppress_no_index=False):
)
index_urls
=
[]
search_scope
=
SearchScope
(
find_links
=
options
.
find_links
,
index_urls
=
index_urls
,
# Make sure find_links is a list before passing to create().
find_links
=
options
.
find_links
or
[]
search_scope
=
SearchScope
.
create
(
find_links
=
find_links
,
index_urls
=
index_urls
,
)
return
search_scope
...
...
tests/unit/test_cmdoptions.py
浏览文件 @
3e73edd3
import
os
import
pretend
import
pytest
from
mock
import
patch
from
pip._internal.cli.cmdoptions
import
(
_convert_python_version
,
...
...
@@ -8,20 +11,24 @@ from pip._internal.cli.cmdoptions import (
@
pytest
.
mark
.
parametrize
(
'no_index, suppress_no_index, expected_index_urls'
,
[
(
False
,
False
,
[
'default_url'
,
'url1'
,
'url2'
]),
(
False
,
True
,
[
'default_url'
,
'url1'
,
'url2'
]),
(
True
,
False
,
[]),
'find_links, no_index, suppress_no_index, expected'
,
[
([
'link1'
],
False
,
False
,
([
'link1'
],
[
'default_url'
,
'url1'
,
'url2'
])),
([
'link1'
],
False
,
True
,
([
'link1'
],
[
'default_url'
,
'url1'
,
'url2'
])),
([
'link1'
],
True
,
False
,
([
'link1'
],
[])),
# Passing suppress_no_index=True suppresses no_index=True.
(
True
,
True
,
[
'default_url'
,
'url1'
,
'url2'
]),
([
'link1'
],
True
,
True
,
([
'link1'
],
[
'default_url'
,
'url1'
,
'url2'
])),
# Test options.find_links=False.
(
False
,
False
,
False
,
([],
[
'default_url'
,
'url1'
,
'url2'
])),
],
)
def
test_make_search_scope
(
no_index
,
suppress_no_index
,
expected_index_urls
):
def
test_make_search_scope
(
find_links
,
no_index
,
suppress_no_index
,
expected
):
"""
:param expected: the expected
index_urls value
.
:param expected: the expected
(find_links, index_urls) values
.
"""
expected_find_links
,
expected_index_urls
=
expected
options
=
pretend
.
stub
(
find_links
=
[
'link1'
]
,
find_links
=
find_links
,
index_url
=
'default_url'
,
extra_index_urls
=
[
'url1'
,
'url2'
],
no_index
=
no_index
,
...
...
@@ -29,10 +36,42 @@ def test_make_search_scope(no_index, suppress_no_index, expected_index_urls):
search_scope
=
make_search_scope
(
options
,
suppress_no_index
=
suppress_no_index
,
)
assert
search_scope
.
find_links
==
[
'link1'
]
assert
search_scope
.
find_links
==
expected_find_links
assert
search_scope
.
index_urls
==
expected_index_urls
@
patch
(
'pip._internal.utils.misc.expanduser'
)
def
test_make_search_scope__find_links_expansion
(
mock_expanduser
,
tmpdir
):
"""
Test "~" expansion in --find-links paths.
"""
# This is a mock version of expanduser() that expands "~" to the tmpdir.
def
expand_path
(
path
):
if
path
.
startswith
(
'~/'
):
path
=
os
.
path
.
join
(
tmpdir
,
path
[
2
:])
return
path
mock_expanduser
.
side_effect
=
expand_path
options
=
pretend
.
stub
(
find_links
=
[
'~/temp1'
,
'~/temp2'
],
index_url
=
'default_url'
,
extra_index_urls
=
[],
no_index
=
False
,
)
# Only create temp2 and not temp1 to test that "~" expansion only occurs
# when the directory exists.
temp2_dir
=
os
.
path
.
join
(
tmpdir
,
'temp2'
)
os
.
mkdir
(
temp2_dir
)
search_scope
=
make_search_scope
(
options
)
# Only ~/temp2 gets expanded. Also, the path is normalized when expanded.
expected_temp2_dir
=
os
.
path
.
normcase
(
temp2_dir
)
assert
search_scope
.
find_links
==
[
'~/temp1'
,
expected_temp2_dir
]
assert
search_scope
.
index_urls
==
[
'default_url'
]
@
pytest
.
mark
.
parametrize
(
'value, expected'
,
[
(
''
,
(
None
,
None
)),
(
'2'
,
((
2
,),
None
)),
...
...
tests/unit/test_unit_outdated.py
浏览文件 @
3e73edd3
...
...
@@ -58,7 +58,7 @@ class MockDistribution(object):
def
_options
():
''' Some default options that we pass to outdated.pip_version_check '''
return
pretend
.
stub
(
find_links
=
False
,
index_url
=
'default_url'
,
extra_index_urls
=
[],
find_links
=
[]
,
index_url
=
'default_url'
,
extra_index_urls
=
[],
no_index
=
False
,
pre
=
False
,
trusted_hosts
=
False
,
cache_dir
=
''
,
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录