Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
9360793a
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,发现更多精彩内容 >>
未验证
提交
9360793a
编写于
4月 10, 2020
作者:
P
Pradyun Gedam
提交者:
GitHub
4月 10, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7987 from deveshks/add-tests-for-pip-cmds-ignoring-cwd
Add unit tests for pip commands not using cwd
上级
c7bde5bf
fe6920bc
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
185 addition
and
8 deletion
+185
-8
news/9E2A89E1-F932-4159-9E69-8AEA7DFD6432.trivial
news/9E2A89E1-F932-4159-9E69-8AEA7DFD6432.trivial
+0
-0
tests/functional/test_check.py
tests/functional/test_check.py
+53
-0
tests/functional/test_freeze.py
tests/functional/test_freeze.py
+38
-0
tests/functional/test_install.py
tests/functional/test_install.py
+50
-0
tests/functional/test_list.py
tests/functional/test_list.py
+5
-8
tests/functional/test_show.py
tests/functional/test_show.py
+39
-0
未找到文件。
news/9E2A89E1-F932-4159-9E69-8AEA7DFD6432.trivial
0 → 100644
浏览文件 @
9360793a
tests/functional/test_check.py
浏览文件 @
9360793a
...
...
@@ -239,3 +239,56 @@ def test_basic_check_broken_metadata(script):
assert
'Error parsing requirements'
in
result
.
stderr
assert
result
.
returncode
==
1
def
test_check_skip_work_dir_pkg
(
script
):
"""
Test that check should not include package
present in working directory
"""
# Create a test package with dependency missing
# and create .egg-info dir
pkg_path
=
create_test_package_with_setup
(
script
,
name
=
'simple'
,
version
=
'1.0'
,
install_requires
=
[
'missing==0.1'
])
script
.
run
(
'python'
,
'setup.py'
,
'egg_info'
,
expect_stderr
=
True
,
cwd
=
pkg_path
)
# Check should not complain about broken requirements
# when run from package directory
result
=
script
.
pip
(
'check'
,
cwd
=
pkg_path
)
expected_lines
=
(
"No broken requirements found."
,
)
assert
matches_expected_lines
(
result
.
stdout
,
expected_lines
)
assert
result
.
returncode
==
0
def
test_check_include_work_dir_pkg
(
script
):
"""
Test that check should include package in working directory
if working directory is added in PYTHONPATH
"""
# Create a test package with dependency missing
# and create .egg-info dir
pkg_path
=
create_test_package_with_setup
(
script
,
name
=
'simple'
,
version
=
'1.0'
,
install_requires
=
[
'missing==0.1'
])
script
.
run
(
'python'
,
'setup.py'
,
'egg_info'
,
expect_stderr
=
True
,
cwd
=
pkg_path
)
script
.
environ
.
update
({
'PYTHONPATH'
:
pkg_path
})
# Check should mention about missing requirement simple
# when run from package directory, when package directory
# is in PYTHONPATH
result
=
script
.
pip
(
'check'
,
expect_error
=
True
,
cwd
=
pkg_path
)
expected_lines
=
(
"simple 1.0 requires missing, which is not installed."
,
)
assert
matches_expected_lines
(
result
.
stdout
,
expected_lines
)
assert
result
.
returncode
==
1
tests/functional/test_freeze.py
浏览文件 @
9360793a
...
...
@@ -11,6 +11,7 @@ from tests.lib import (
_create_test_package_with_srcdir
,
_git_commit
,
_vcs_add
,
create_test_package_with_setup
,
need_bzr
,
need_mercurial
,
need_svn
,
...
...
@@ -824,3 +825,40 @@ def test_freeze_direct_url_archive(script, shared_data, with_wheel):
script
.
pip
(
"install"
,
req
)
result
=
script
.
pip
(
"freeze"
)
assert
req
in
result
.
stdout
def
test_freeze_skip_work_dir_pkg
(
script
):
"""
Test that freeze should not include package
present in working directory
"""
# Create a test package and create .egg-info dir
pkg_path
=
create_test_package_with_setup
(
script
,
name
=
'simple'
,
version
=
'1.0'
)
script
.
run
(
'python'
,
'setup.py'
,
'egg_info'
,
expect_stderr
=
True
,
cwd
=
pkg_path
)
# Freeze should not include package simple when run from package directory
result
=
script
.
pip
(
'freeze'
,
cwd
=
pkg_path
)
assert
'simple'
not
in
result
.
stdout
def
test_freeze_include_work_dir_pkg
(
script
):
"""
Test that freeze should include package in working directory
if working directory is added in PYTHONPATH
"""
# Create a test package and create .egg-info dir
pkg_path
=
create_test_package_with_setup
(
script
,
name
=
'simple'
,
version
=
'1.0'
)
script
.
run
(
'python'
,
'setup.py'
,
'egg_info'
,
expect_stderr
=
True
,
cwd
=
pkg_path
)
script
.
environ
.
update
({
'PYTHONPATH'
:
pkg_path
})
# Freeze should include package simple when run from package directory,
# when package directory is in PYTHONPATH
result
=
script
.
pip
(
'freeze'
,
cwd
=
pkg_path
)
assert
'simple==1.0'
in
result
.
stdout
tests/functional/test_install.py
浏览文件 @
9360793a
...
...
@@ -1846,3 +1846,53 @@ def test_install_sends_client_cert(install_args, script, cert_factory, data):
environ
,
_
=
call_args
.
args
assert
"SSL_CLIENT_CERT"
in
environ
assert
environ
[
"SSL_CLIENT_CERT"
]
def
test_install_skip_work_dir_pkg
(
script
,
data
):
"""
Test that install of a package in working directory
should pass on the second attempt after an install
and an uninstall
"""
# Create a test package and install it
pkg_path
=
create_test_package_with_setup
(
script
,
name
=
'simple'
,
version
=
'1.0'
)
script
.
pip
(
'install'
,
'-e'
,
'.'
,
expect_stderr
=
True
,
cwd
=
pkg_path
)
# Uninstalling the package and installing it again will succeed
script
.
pip
(
'uninstall'
,
'simple'
,
'-y'
)
result
=
script
.
pip
(
'install'
,
'--find-links'
,
data
.
find_links
,
'simple'
,
expect_stderr
=
True
,
cwd
=
pkg_path
)
assert
'Requirement already satisfied: simple'
not
in
result
.
stdout
assert
'Successfully installed simple'
in
result
.
stdout
def
test_install_include_work_dir_pkg
(
script
,
data
):
"""
Test that install of a package in working directory
should fail on the second attempt after an install
if working directory is added in PYTHONPATH
"""
# Create a test package and install it
pkg_path
=
create_test_package_with_setup
(
script
,
name
=
'simple'
,
version
=
'1.0'
)
script
.
pip
(
'install'
,
'-e'
,
'.'
,
expect_stderr
=
True
,
cwd
=
pkg_path
)
# Uninstall will fail with given warning
script
.
pip
(
'uninstall'
,
'simple'
,
'-y'
)
script
.
environ
.
update
({
'PYTHONPATH'
:
pkg_path
})
# Uninstalling the package and installing it again will fail,
# when package directory is in PYTHONPATH
result
=
script
.
pip
(
'install'
,
'--find-links'
,
data
.
find_links
,
'simple'
,
expect_stderr
=
True
,
cwd
=
pkg_path
)
assert
'Requirement already satisfied: simple'
in
result
.
stdout
tests/functional/test_list.py
浏览文件 @
9360793a
...
...
@@ -552,9 +552,8 @@ def test_list_skip_work_dir_pkg(script):
"""
# Create a test package and create .egg-info dir
pkg_path
=
create_test_package_with_setup
(
script
,
name
=
'simple'
,
version
=
'1.0'
)
pkg_path
=
create_test_package_with_setup
(
script
,
name
=
'simple'
,
version
=
'1.0'
)
script
.
run
(
'python'
,
'setup.py'
,
'egg_info'
,
expect_stderr
=
True
,
cwd
=
pkg_path
)
...
...
@@ -567,14 +566,12 @@ def test_list_skip_work_dir_pkg(script):
def
test_list_include_work_dir_pkg
(
script
):
"""
Test that list should include package in working directory
if working directory is added in
sys.path
if working directory is added in
PYTHONPATH
"""
# Create a test package and create .egg-info dir
pkg_path
=
create_test_package_with_setup
(
script
,
name
=
'simple'
,
version
=
'1.0'
)
pkg_path
=
create_test_package_with_setup
(
script
,
name
=
'simple'
,
version
=
'1.0'
)
script
.
run
(
'python'
,
'setup.py'
,
'egg_info'
,
expect_stderr
=
True
,
cwd
=
pkg_path
)
...
...
tests/functional/test_show.py
浏览文件 @
9360793a
...
...
@@ -5,6 +5,7 @@ import pytest
from
pip
import
__version__
from
pip._internal.commands.show
import
search_packages_info
from
tests.lib
import
create_test_package_with_setup
def
test_basic_show
(
script
):
...
...
@@ -259,3 +260,41 @@ def test_show_required_by_packages_requiring_capitalized(script, data):
assert
'Name: Requires-Capitalized'
in
lines
assert
'Required-by: requires-requires-capitalized'
in
lines
def
test_show_skip_work_dir_pkg
(
script
):
"""
Test that show should not include package
present in working directory
"""
# Create a test package and create .egg-info dir
pkg_path
=
create_test_package_with_setup
(
script
,
name
=
'simple'
,
version
=
'1.0'
)
script
.
run
(
'python'
,
'setup.py'
,
'egg_info'
,
expect_stderr
=
True
,
cwd
=
pkg_path
)
# Show should not include package simple when run from package directory
result
=
script
.
pip
(
'show'
,
'simple'
,
expect_error
=
True
,
cwd
=
pkg_path
)
assert
'WARNING: Package(s) not found: simple'
in
result
.
stderr
def
test_show_include_work_dir_pkg
(
script
):
"""
Test that show should include package in working directory
if working directory is added in PYTHONPATH
"""
# Create a test package and create .egg-info dir
pkg_path
=
create_test_package_with_setup
(
script
,
name
=
'simple'
,
version
=
'1.0'
)
script
.
run
(
'python'
,
'setup.py'
,
'egg_info'
,
expect_stderr
=
True
,
cwd
=
pkg_path
)
script
.
environ
.
update
({
'PYTHONPATH'
:
pkg_path
})
# Show should include package simple when run from package directory,
# when package directory is in PYTHONPATH
result
=
script
.
pip
(
'show'
,
'simple'
,
cwd
=
pkg_path
)
lines
=
result
.
stdout
.
splitlines
()
assert
'Name: simple'
in
lines
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录