Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
1e8b6c2f
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,发现更多精彩内容 >>
提交
1e8b6c2f
编写于
5月 14, 2016
作者:
X
Xavier Fernandez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve tests
Demote "Ignoring indexes" log to DEBUG to enable stdout JSON parsing
上级
6a7f82ba
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
81 addition
and
98 deletion
+81
-98
pip/basecommand.py
pip/basecommand.py
+1
-1
pip/commands/list.py
pip/commands/list.py
+2
-13
pip/commands/wheel.py
pip/commands/wheel.py
+1
-1
tests/functional/test_list.py
tests/functional/test_list.py
+77
-83
未找到文件。
pip/basecommand.py
浏览文件 @
1e8b6c2f
...
...
@@ -317,7 +317,7 @@ class RequirementCommand(Command):
"""
index_urls
=
[
options
.
index_url
]
+
options
.
extra_index_urls
if
options
.
no_index
:
logger
.
info
(
'Ignoring indexes: %s'
,
','
.
join
(
index_urls
))
logger
.
debug
(
'Ignoring indexes: %s'
,
','
.
join
(
index_urls
))
index_urls
=
[]
return
PackageFinder
(
...
...
pip/commands/list.py
浏览文件 @
1e8b6c2f
...
...
@@ -80,28 +80,17 @@ class ListCommand(Command):
dest
=
'list_format'
,
choices
=
(
'legacy'
,
'columns'
,
'freeze'
,
'json'
),
help
=
"Select the output format among: legacy (default), columns, "
"freeze or json"
,
"freeze or json
.
"
,
)
# TODO: When we switch the default, set default=True here.
cmd_opts
.
add_option
(
'--columns'
,
action
=
'store_const'
,
const
=
'columns'
,
dest
=
'list_format'
,
# default=True,
help
=
"Align package names and versions into vertical columns."
,
)
cmd_opts
.
add_option
(
'--no-columns'
,
action
=
'store_const'
,
const
=
'legacy'
,
dest
=
'list_format'
,
help
=
(
"Do not align package names and versions into "
"vertical columns (old-style formatting)"
),
)
index_opts
=
make_option_group
(
index_group
,
self
.
parser
)
self
.
parser
.
insert_option_group
(
0
,
index_opts
)
...
...
@@ -183,7 +172,7 @@ class ListCommand(Command):
def
iter_packages_latest_infos
(
self
,
packages
,
options
):
index_urls
=
[
options
.
index_url
]
+
options
.
extra_index_urls
if
options
.
no_index
:
logger
.
info
(
'Ignoring indexes: %s'
,
','
.
join
(
index_urls
))
logger
.
debug
(
'Ignoring indexes: %s'
,
','
.
join
(
index_urls
))
index_urls
=
[]
dependency_links
=
[]
...
...
pip/commands/wheel.py
浏览文件 @
1e8b6c2f
...
...
@@ -151,7 +151,7 @@ class WheelCommand(RequirementCommand):
index_urls
=
[
options
.
index_url
]
+
options
.
extra_index_urls
if
options
.
no_index
:
logger
.
info
(
'Ignoring indexes: %s'
,
','
.
join
(
index_urls
))
logger
.
debug
(
'Ignoring indexes: %s'
,
','
.
join
(
index_urls
))
index_urls
=
[]
if
options
.
build_dir
:
...
...
tests/functional/test_list.py
浏览文件 @
1e8b6c2f
...
...
@@ -2,17 +2,23 @@ import json
import
os
import
pytest
WARN_FORMAT
=
(
"DEPRECATION: The default format will switch to columns in the "
"future. You can use --format=legacy (or define a list_format "
"in your pip.conf) to disable this warning."
)
def
test_list_command
(
script
,
data
):
"""
Test default behavior of list command.
Test default behavior of list command without format specifier.
A warning is expected.
"""
script
.
pip
(
'install'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'simple==1.0'
,
'simple2==3.0'
,
)
result
=
script
.
pip
(
'list'
)
result
=
script
.
pip
(
'list'
,
expect_stderr
=
True
)
assert
WARN_FORMAT
in
result
.
stderr
,
str
(
result
)
assert
'simple (1.0)'
in
result
.
stdout
,
str
(
result
)
assert
'simple2 (3.0)'
in
result
.
stdout
,
str
(
result
)
...
...
@@ -33,49 +39,34 @@ def test_columns_flag(script, data):
assert
'simple2 3.0'
in
result
.
stdout
,
str
(
result
)
def
test_
nocolumns_flag
(
script
,
data
):
def
test_
legacy_format
(
script
,
data
):
"""
Test that --no-columns raises the deprecation warning and still outputs
the old-style formatting.
Test that legacy format
"""
script
.
pip
(
'install'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'simple==1.0'
,
'simple2==3.0'
,
)
result
=
script
.
pip
(
'list'
,
'--
no-columns'
,
expect_stderr
=
True
)
result
=
script
.
pip
(
'list'
,
'--
format=legacy'
)
assert
'simple (1.0)'
in
result
.
stdout
,
str
(
result
)
assert
'simple2 (3.0)'
in
result
.
stdout
,
str
(
result
)
def
test_
columns_nocolumns
(
script
,
data
):
def
test_
format_priority
(
script
,
data
):
"""
Test that
--no-columns has priority in --columns --no-column
s.
Test that
latest format has priority over previous one
s.
"""
script
.
pip
(
'install'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'simple==1.0'
,
'simple2==3.0'
,
)
result
=
script
.
pip
(
'list'
,
'--columns'
,
'--no-columns'
,
expect_error
=
True
,
)
result
=
script
.
pip
(
'list'
,
'--format=columns'
,
'--format=legacy'
)
assert
'simple (1.0)'
in
result
.
stdout
,
str
(
result
)
assert
'simple2 (3.0)'
in
result
.
stdout
,
str
(
result
)
assert
'simple 1.0'
not
in
result
.
stdout
,
str
(
result
)
assert
'simple2 3.0'
not
in
result
.
stdout
,
str
(
result
)
def
test_nocolumns_columns
(
script
,
data
):
"""
Test that --columns has priority in --no-columns --columns.
"""
script
.
pip
(
'install'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'simple==1.0'
,
'simple2==3.0'
,
)
result
=
script
.
pip
(
'list'
,
'--no-columns'
,
'--columns'
,
)
result
=
script
.
pip
(
'list'
,
'--format=legacy'
,
'--columns'
)
assert
'Package'
in
result
.
stdout
,
str
(
result
)
assert
'Version'
in
result
.
stdout
,
str
(
result
)
assert
'simple (1.0)'
not
in
result
.
stdout
,
str
(
result
)
...
...
@@ -90,7 +81,7 @@ def test_local_flag(script, data):
"""
script
.
pip
(
'install'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'simple==1.0'
)
result
=
script
.
pip
(
'list'
,
'--local'
)
result
=
script
.
pip
(
'list'
,
'--local'
,
'--format=legacy'
)
assert
'simple (1.0)'
in
result
.
stdout
...
...
@@ -107,13 +98,13 @@ def test_local_columns_flag(script, data):
assert
'simple 1.0'
in
result
.
stdout
,
str
(
result
)
def
test_local_
nocolumns
_flag
(
script
,
data
):
def
test_local_
legacy
_flag
(
script
,
data
):
"""
Test the behavior of --local --
no-columns
flags in the list
Test the behavior of --local --
format=legacy
flags in the list
command.
"""
script
.
pip
(
'install'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'simple==1.0'
)
result
=
script
.
pip
(
'list'
,
'--local'
,
'--
no-columns'
,
expect_stderr
=
True
)
result
=
script
.
pip
(
'list'
,
'--local'
,
'--
format=legacy'
)
assert
'simple (1.0)'
in
result
.
stdout
...
...
@@ -126,7 +117,7 @@ def test_user_flag(script, data, virtualenv):
script
.
pip
(
'install'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'simple==1.0'
)
script
.
pip
(
'install'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'--user'
,
'simple2==2.0'
)
result
=
script
.
pip
(
'list'
,
'--user'
)
result
=
script
.
pip
(
'list'
,
'--user'
,
'--format=legacy'
)
assert
'simple (1.0)'
not
in
result
.
stdout
assert
'simple2 (2.0)'
in
result
.
stdout
...
...
@@ -147,7 +138,7 @@ def test_user_columns_flag(script, data, virtualenv):
assert
'simple2 2.0'
in
result
.
stdout
,
str
(
result
)
def
test_user_
nocolumns_flag
(
script
,
data
,
virtualenv
):
def
test_user_
legacy
(
script
,
data
,
virtualenv
):
"""
Test the behavior of --user flag in the list command
...
...
@@ -156,7 +147,7 @@ def test_user_nocolumns_flag(script, data, virtualenv):
script
.
pip
(
'install'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'simple==1.0'
)
script
.
pip
(
'install'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'--user'
,
'simple2==2.0'
)
result
=
script
.
pip
(
'list'
,
'--user'
,
'--
no-columns'
,
expect_stderr
=
True
)
result
=
script
.
pip
(
'list'
,
'--user'
,
'--
format=legacy'
)
assert
'simple (1.0)'
not
in
result
.
stdout
assert
'simple2 (2.0)'
in
result
.
stdout
,
str
(
result
)
...
...
@@ -177,7 +168,7 @@ def test_uptodate_flag(script, data):
)
result
=
script
.
pip
(
'list'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'--uptodate'
,
expect_stderr
=
True
,
'--format=legacy'
,
)
assert
'simple (1.0)'
not
in
result
.
stdout
# 3.0 is latest
assert
'pip-test-package (0.1.1,'
in
result
.
stdout
# editables included
...
...
@@ -211,9 +202,9 @@ def test_uptodate_columns_flag(script, data):
@
pytest
.
mark
.
network
def
test_uptodate_
nocolumns
_flag
(
script
,
data
):
def
test_uptodate_
legacy
_flag
(
script
,
data
):
"""
Test the behavior of --uptodate --
no-columns
flag in the list command
Test the behavior of --uptodate --
format=legacy
flag in the list command
"""
script
.
pip
(
...
...
@@ -226,7 +217,7 @@ def test_uptodate_nocolumns_flag(script, data):
)
result
=
script
.
pip
(
'list'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'--uptodate'
,
'--
no-columns'
,
expect_stderr
=
True
,
'--
format=legacy'
,
)
assert
'simple (1.0)'
not
in
result
.
stdout
# 3.0 is latest
assert
'pip-test-package (0.1.1,'
in
result
.
stdout
# editables included
...
...
@@ -250,7 +241,7 @@ def test_outdated_flag(script, data):
)
result
=
script
.
pip
(
'list'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'--outdated'
,
expect_stderr
=
True
,
'--format=legacy'
,
)
assert
'simple (1.0) - Latest: 3.0 [sdist]'
in
result
.
stdout
assert
'simplewheel (1.0) - Latest: 2.0 [wheel]'
in
result
.
stdout
...
...
@@ -294,9 +285,9 @@ def test_outdated_columns_flag(script, data):
@
pytest
.
mark
.
network
def
test_outdated_
nocolumns_flag
(
script
,
data
):
def
test_outdated_
legacy
(
script
,
data
):
"""
Test the behavior of --outdated --
no-columns
flag in the list command
Test the behavior of --outdated --
format=legacy
flag in the list command
"""
script
.
pip
(
...
...
@@ -310,7 +301,7 @@ def test_outdated_nocolumns_flag(script, data):
)
result
=
script
.
pip
(
'list'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'--outdated'
,
'--
no-columns'
,
expect_stderr
=
True
,
'--
format=legacy'
,
)
assert
'simple (1.0) - Latest: 3.0 [sdist]'
in
result
.
stdout
assert
'simplewheel (1.0) - Latest: 2.0 [wheel]'
in
result
.
stdout
...
...
@@ -329,7 +320,7 @@ def test_editables_flag(script, data):
'install'
,
'-e'
,
'git+https://github.com/pypa/pip-test-package.git#egg=pip-test-package'
)
result
=
script
.
pip
(
'list'
,
'--editable'
)
result
=
script
.
pip
(
'list'
,
'--editable'
,
'--format=legacy'
)
assert
'simple (1.0)'
not
in
result
.
stdout
,
str
(
result
)
assert
os
.
path
.
join
(
'src'
,
'pip-test-package'
)
in
result
.
stdout
,
(
str
(
result
)
...
...
@@ -356,7 +347,7 @@ def test_editables_columns_flag(script, data):
@
pytest
.
mark
.
network
def
test_editables_
nocolumns_flag
(
script
,
data
):
def
test_editables_
legacy
(
script
,
data
):
"""
Test the behavior of --editables flag in the list command
"""
...
...
@@ -366,7 +357,7 @@ def test_editables_nocolumns_flag(script, data):
'git+https://github.com/pypa/pip-test-package.git#egg=pip-test-package'
)
result
=
script
.
pip
(
'list'
,
'--editable'
,
'--
no-columns
'
,
expect_stderr
=
True
,
'list'
,
'--editable'
,
'--
format=legacy
'
,
expect_stderr
=
True
,
)
assert
'simple (1.0)'
not
in
result
.
stdout
,
str
(
result
)
assert
os
.
path
.
join
(
'src'
,
'pip-test-package'
)
in
result
.
stdout
,
(
...
...
@@ -387,7 +378,7 @@ def test_uptodate_editables_flag(script, data):
result
=
script
.
pip
(
'list'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'--editable'
,
'--uptodate'
,
expect_stderr
=
True
,
'--format=legacy'
,
)
assert
'simple (1.0)'
not
in
result
.
stdout
,
str
(
result
)
assert
os
.
path
.
join
(
'src'
,
'pip-test-package'
)
in
result
.
stdout
,
(
...
...
@@ -419,9 +410,9 @@ def test_uptodate_editables_columns_flag(script, data):
@
pytest
.
mark
.
network
def
test_uptodate_editables_
nocolumns_flag
(
script
,
data
):
def
test_uptodate_editables_
legacy
(
script
,
data
):
"""
test the behavior of --editable --uptodate --columns --
no-columns
flag
test the behavior of --editable --uptodate --columns --
format=legacy
flag
in the list command
"""
script
.
pip
(
'install'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'simple==1.0'
)
...
...
@@ -431,7 +422,7 @@ def test_uptodate_editables_nocolumns_flag(script, data):
)
result
=
script
.
pip
(
'list'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'--editable'
,
'--uptodate'
,
'--
no-columns'
,
expect_stderr
=
True
,
'--uptodate'
,
'--
format=legacy'
,
)
assert
'simple (1.0)'
not
in
result
.
stdout
,
str
(
result
)
assert
os
.
path
.
join
(
'src'
,
'pip-test-package'
)
in
result
.
stdout
,
(
...
...
@@ -453,7 +444,7 @@ def test_outdated_editables_flag(script, data):
result
=
script
.
pip
(
'list'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'--editable'
,
'--outdated'
,
expect_stderr
=
True
,
'--format=legacy'
,
)
assert
'simple (1.0)'
not
in
result
.
stdout
,
str
(
result
)
assert
os
.
path
.
join
(
'src'
,
'pip-test-package'
)
in
result
.
stdout
,
(
...
...
@@ -485,7 +476,7 @@ def test_outdated_editables_columns_flag(script, data):
@
pytest
.
mark
.
network
def
test_outdated_editables_
nocolumns_flag
(
script
,
data
):
def
test_outdated_editables_
legacy
(
script
,
data
):
"""
test the behavior of --editable --outdated flag in the list command
"""
...
...
@@ -497,8 +488,7 @@ def test_outdated_editables_nocolumns_flag(script, data):
)
result
=
script
.
pip
(
'list'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'--editable'
,
'--outdated'
,
'--no-columns'
,
expect_stderr
=
True
,
'--editable'
,
'--outdated'
,
'--format=legacy'
,
)
assert
'simple (1.0)'
not
in
result
.
stdout
,
str
(
result
)
assert
os
.
path
.
join
(
'src'
,
'pip-test-package'
)
in
result
.
stdout
,
(
...
...
@@ -514,60 +504,64 @@ def test_outdated_pre(script, data):
wheelhouse_path
=
script
.
scratch_path
/
'wheelhouse'
wheelhouse_path
.
join
(
'simple-1.1-py2.py3-none-any.whl'
).
write
(
''
)
wheelhouse_path
.
join
(
'simple-2.0.dev0-py2.py3-none-any.whl'
).
write
(
''
)
result
=
script
.
pip
(
'list'
,
'--no-index'
,
'--find-links'
,
wheelhouse_path
)
result
=
script
.
pip
(
'list'
,
'--no-index'
,
'--find-links'
,
wheelhouse_path
,
'--format=legacy'
,
)
assert
'simple (1.0)'
in
result
.
stdout
result
=
script
.
pip
(
'list'
,
'--no-index'
,
'--find-links'
,
wheelhouse_path
,
'--outdated'
)
result
=
script
.
pip
(
'list'
,
'--no-index'
,
'--find-links'
,
wheelhouse_path
,
'--outdated'
,
'--format=legacy'
,
)
assert
'simple (1.0) - Latest: 1.1 [wheel]'
in
result
.
stdout
result_pre
=
script
.
pip
(
'list'
,
'--no-index'
,
'--find-links'
,
wheelhouse_path
,
'--outdated'
,
'--pre'
)
'--outdated'
,
'--pre'
,
'--format=legacy'
)
assert
'simple (1.0) - Latest: 2.0.dev0 [wheel]'
in
result_pre
.
stdout
def
test_outdated_
pre_column
s
(
script
,
data
):
""" Test of
interaction behavior of --pre and --column
s """
def
test_outdated_
format
s
(
script
,
data
):
""" Test of
different outdated format
s """
script
.
pip
(
'install'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'simple==1.0'
)
# Let's build a fake wheelhouse
script
.
scratch_path
.
join
(
"wheelhouse"
).
mkdir
()
wheelhouse_path
=
script
.
scratch_path
/
'wheelhouse'
wheelhouse_path
.
join
(
'simple-1.1-py2.py3-none-any.whl'
).
write
(
''
)
wheelhouse_path
.
join
(
'simple-2.0.dev0-py2.py3-none-any.whl'
).
write
(
''
)
result
=
script
.
pip
(
'list'
,
'--no-index'
,
'--find-links'
,
wheelhouse_path
)
assert
'simple (1.0)'
in
result
.
stdout
result
=
script
.
pip
(
'list'
,
'--no-index'
,
'--find-links'
,
wheelhouse_path
,
'--format=freeze'
,
)
assert
'simple==1.0'
in
result
.
stdout
# Check legacy
result
=
script
.
pip
(
'list'
,
'--no-index'
,
'--find-links'
,
wheelhouse_path
,
'--outdated'
)
'--outdated'
,
'--format=legacy'
)
assert
'simple (1.0) - Latest: 1.1 [wheel]'
in
result
.
stdout
result_pre
=
script
.
pip
(
# Check columns
result
=
script
.
pip
(
'list'
,
'--no-index'
,
'--find-links'
,
wheelhouse_path
,
'--outdated'
,
'--
pre'
,
'--
columns'
,
'--outdated'
,
'--columns'
,
)
assert
'Package'
in
result_pre
.
stdout
assert
'Version'
in
result_pre
.
stdout
assert
'Latest'
in
result_pre
.
stdout
assert
'Type'
in
result_pre
.
stdout
assert
'Package Version Latest Type'
in
result
.
stdout
assert
'simple 1.0 1.1 wheel'
in
result
.
stdout
# Check freeze
result
=
script
.
pip
(
'list'
,
'--no-index'
,
'--find-links'
,
wheelhouse_path
,
'--outdated'
,
'--format=freeze'
,
)
assert
'simple==1.0'
in
result
.
stdout
def
test_outdated_pre_nocolumns
(
script
,
data
):
""" Test of interaction behavior of --pre and --no-columns """
script
.
pip
(
'install'
,
'-f'
,
data
.
find_links
,
'--no-index'
,
'simple==1.0'
)
# Let's build a fake wheelhouse
script
.
scratch_path
.
join
(
"wheelhouse"
).
mkdir
()
wheelhouse_path
=
script
.
scratch_path
/
'wheelhouse'
wheelhouse_path
.
join
(
'simple-1.1-py2.py3-none-any.whl'
).
write
(
''
)
wheelhouse_path
.
join
(
'simple-2.0.dev0-py2.py3-none-any.whl'
).
write
(
''
)
result
=
script
.
pip
(
'list'
,
'--no-index'
,
'--find-links'
,
wheelhouse_path
)
assert
'simple (1.0)'
in
result
.
stdout
result
=
script
.
pip
(
'list'
,
'--no-index'
,
'--find-links'
,
wheelhouse_path
,
'--outdated'
)
assert
'simple (1.0) - Latest: 1.1 [wheel]'
in
result
.
stdout
# Check json
result
=
script
.
pip
(
'list'
,
'--no-index'
,
'--find-links'
,
wheelhouse_path
,
'--outdated'
,
'--pre'
,
'--no-columns'
,
expect_stderr
=
True
'list'
,
'--no-index'
,
'--find-links'
,
wheelhouse_path
,
'--outdated'
,
'--format=json'
,
)
data
=
json
.
loads
(
result
.
stdout
)
assert
data
==
[{
'name'
:
'simple'
,
'version'
:
'1.0'
,
'latest_version'
:
'1.1'
,
'latest_filetype'
:
'wheel'
}]
def
test_list_freeze
(
script
,
data
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录