Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
f9a3b97b
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,发现更多精彩内容 >>
提交
f9a3b97b
编写于
8月 22, 2013
作者:
D
Donald Stufft
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Explicitly pass around a directory for tests.lib.local_repos
上级
0c42245f
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
96 addition
and
100 deletion
+96
-100
tests/functional/test_bundle.py
tests/functional/test_bundle.py
+5
-5
tests/functional/test_freeze.py
tests/functional/test_freeze.py
+16
-16
tests/functional/test_install.py
tests/functional/test_install.py
+21
-21
tests/functional/test_install_cleanup.py
tests/functional/test_install_cleanup.py
+2
-2
tests/functional/test_install_index.py
tests/functional/test_install_index.py
+1
-1
tests/functional/test_install_reqs.py
tests/functional/test_install_reqs.py
+2
-2
tests/functional/test_install_upgrade.py
tests/functional/test_install_upgrade.py
+2
-2
tests/functional/test_install_user.py
tests/functional/test_install_user.py
+2
-2
tests/functional/test_install_vcs.py
tests/functional/test_install_vcs.py
+14
-13
tests/functional/test_uninstall.py
tests/functional/test_uninstall.py
+11
-9
tests/lib/local_repos.py
tests/lib/local_repos.py
+20
-27
未找到文件。
tests/functional/test_bundle.py
浏览文件 @
f9a3b97b
...
...
@@ -7,7 +7,7 @@ from tests.lib.path import Path
from
tests.lib.local_repos
import
local_checkout
def
test_create_bundle
(
script
):
def
test_create_bundle
(
script
,
tmpdir
):
"""
Test making a bundle. We'll grab one package from the filesystem
(the FSPkg dummy package), one from vcs (initools) and one from an
...
...
@@ -19,7 +19,7 @@ def test_create_bundle(script):
pkg_lines
=
textwrap
.
dedent
(
'''
\
-e %s
-e %s#egg=initools-dev
pip'''
%
(
fspkg
,
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
)))
pip'''
%
(
fspkg
,
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
,
tmpdir
.
join
(
"cache"
)
)))
script
.
scratch_path
.
join
(
"bundle-req.txt"
).
write
(
pkg_lines
)
# Create a bundle in env.scratch_path/ test.pybundle
result
=
script
.
pip
(
'bundle'
,
'-r'
,
script
.
scratch_path
/
'bundle-req.txt'
,
script
.
scratch_path
/
'test.pybundle'
)
...
...
@@ -32,7 +32,7 @@ def test_create_bundle(script):
assert
'build/pip/'
in
files
def
test_cleanup_after_create_bundle
(
script
):
def
test_cleanup_after_create_bundle
(
script
,
tmpdir
):
"""
Test clean up after making a bundle. Make sure (build|src)-bundle/ dirs are removed but not src/.
...
...
@@ -41,7 +41,7 @@ def test_cleanup_after_create_bundle(script):
args
=
[
'install'
]
args
.
extend
([
'-e'
,
'%s#egg=pip-test-package'
%
local_checkout
(
'git+http://github.com/pypa/pip-test-package.git'
)])
local_checkout
(
'git+http://github.com/pypa/pip-test-package.git'
,
tmpdir
.
join
(
"cache"
)
)])
script
.
pip
(
*
args
)
build
=
script
.
venv_path
/
"build"
src
=
script
.
venv_path
/
"src"
...
...
@@ -53,7 +53,7 @@ def test_cleanup_after_create_bundle(script):
pkg_lines
=
textwrap
.
dedent
(
'''
\
-e %s
-e %s#egg=initools-dev
pip'''
%
(
fspkg
,
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
)))
pip'''
%
(
fspkg
,
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
,
tmpdir
.
join
(
"cache"
)
)))
script
.
scratch_path
.
join
(
"bundle-req.txt"
).
write
(
pkg_lines
)
script
.
pip
(
'bundle'
,
'-r'
,
'bundle-req.txt'
,
'test.pybundle'
)
build_bundle
=
script
.
scratch_path
/
"build-bundle"
...
...
tests/functional/test_freeze.py
浏览文件 @
f9a3b97b
...
...
@@ -58,15 +58,15 @@ def test_freeze_basic(script):
_check_output
(
result
,
expected
)
def
test_freeze_svn
(
script
):
def
test_freeze_svn
(
script
,
tmpdir
):
"""Test freezing a svn checkout"""
checkout_path
=
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
)
checkout_path
=
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
,
tmpdir
.
join
(
"cache"
)
)
#svn internally stores windows drives as uppercase; we'll match that.
checkout_path
=
checkout_path
.
replace
(
'c:'
,
'C:'
)
result
=
script
.
run
(
'svn'
,
'co'
,
'-r10'
,
local_repo
(
'svn+http://svn.colorstudy.com/INITools/trunk'
),
local_repo
(
'svn+http://svn.colorstudy.com/INITools/trunk'
,
tmpdir
.
join
(
"cache"
)
),
'initools-trunk'
)
result
=
script
.
run
(
'python'
,
'setup.py'
,
'develop'
,
cwd
=
script
.
scratch_path
/
'initools-trunk'
,
expect_stderr
=
True
)
...
...
@@ -79,12 +79,12 @@ def test_freeze_svn(script):
_check_output
(
result
,
expected
)
def
test_freeze_git_clone
(
script
):
def
test_freeze_git_clone
(
script
,
tmpdir
):
"""
Test freezing a Git clone.
"""
result
=
script
.
run
(
'git'
,
'clone'
,
local_repo
(
'git+http://github.com/pypa/pip-test-package.git'
),
'pip-test-package'
)
result
=
script
.
run
(
'git'
,
'clone'
,
local_repo
(
'git+http://github.com/pypa/pip-test-package.git'
,
tmpdir
.
join
(
"cache"
)
),
'pip-test-package'
)
result
=
script
.
run
(
'git'
,
'checkout'
,
'7d654e66c8fa7149c165ddeffa5b56bc06619458'
,
cwd
=
script
.
scratch_path
/
'pip-test-package'
,
expect_stderr
=
True
)
result
=
script
.
run
(
'python'
,
'setup.py'
,
'develop'
,
...
...
@@ -94,29 +94,29 @@ def test_freeze_git_clone(script):
Script result: ...pip freeze
-- stdout: --------------------
...-e %s@...#egg=pip_test_package-...
..."""
%
local_checkout
(
'git+http://github.com/pypa/pip-test-package.git'
))
..."""
%
local_checkout
(
'git+http://github.com/pypa/pip-test-package.git'
,
tmpdir
.
join
(
"cache"
)
))
_check_output
(
result
,
expected
)
result
=
script
.
pip
(
'freeze'
,
'-f'
,
'%s#egg=pip_test_package'
%
local_checkout
(
'git+http://github.com/pypa/pip-test-package.git'
),
'%s#egg=pip_test_package'
%
local_checkout
(
'git+http://github.com/pypa/pip-test-package.git'
,
tmpdir
.
join
(
"cache"
)
),
expect_stderr
=
True
)
expected
=
textwrap
.
dedent
(
"""
\
Script result: pip freeze -f %(repo)s#egg=pip_test_package
-- stdout: --------------------
-f %(repo)s#egg=pip_test_package...
-e %(repo)s@...#egg=pip_test_package-0.1.1
..."""
%
{
'repo'
:
local_checkout
(
'git+http://github.com/pypa/pip-test-package.git'
)})
..."""
%
{
'repo'
:
local_checkout
(
'git+http://github.com/pypa/pip-test-package.git'
,
tmpdir
.
join
(
"cache"
)
)})
_check_output
(
result
,
expected
)
def
test_freeze_mercurial_clone
(
script
):
def
test_freeze_mercurial_clone
(
script
,
tmpdir
):
"""
Test freezing a Mercurial clone.
"""
result
=
script
.
run
(
'hg'
,
'clone'
,
'-r'
,
'c9963c111e7c'
,
local_repo
(
'hg+http://bitbucket.org/pypa/pip-test-package'
),
local_repo
(
'hg+http://bitbucket.org/pypa/pip-test-package'
,
tmpdir
.
join
(
"cache"
)
),
'pip-test-package'
)
result
=
script
.
run
(
'python'
,
'setup.py'
,
'develop'
,
cwd
=
script
.
scratch_path
/
'pip-test-package'
,
expect_stderr
=
True
)
...
...
@@ -125,33 +125,33 @@ def test_freeze_mercurial_clone(script):
Script result: ...pip freeze
-- stdout: --------------------
...-e %s@...#egg=pip_test_package-...
..."""
%
local_checkout
(
'hg+http://bitbucket.org/pypa/pip-test-package'
))
..."""
%
local_checkout
(
'hg+http://bitbucket.org/pypa/pip-test-package'
,
tmpdir
.
join
(
"cache"
)
))
_check_output
(
result
,
expected
)
result
=
script
.
pip
(
'freeze'
,
'-f'
,
'%s#egg=pip_test_package'
%
local_checkout
(
'hg+http://bitbucket.org/pypa/pip-test-package'
),
'%s#egg=pip_test_package'
%
local_checkout
(
'hg+http://bitbucket.org/pypa/pip-test-package'
,
tmpdir
.
join
(
"cache"
)
),
expect_stderr
=
True
)
expected
=
textwrap
.
dedent
(
"""
\
Script result: ...pip freeze -f %(repo)s#egg=pip_test_package
-- stdout: --------------------
-f %(repo)s#egg=pip_test_package
...-e %(repo)s@...#egg=pip_test_package-dev
..."""
%
{
'repo'
:
local_checkout
(
'hg+http://bitbucket.org/pypa/pip-test-package'
)})
..."""
%
{
'repo'
:
local_checkout
(
'hg+http://bitbucket.org/pypa/pip-test-package'
,
tmpdir
.
join
(
"cache"
)
)})
_check_output
(
result
,
expected
)
def
test_freeze_bazaar_clone
(
script
):
def
test_freeze_bazaar_clone
(
script
,
tmpdir
):
"""
Test freezing a Bazaar clone.
"""
checkout_path
=
local_checkout
(
'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'
)
checkout_path
=
local_checkout
(
'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'
,
tmpdir
.
join
(
"cache"
)
)
#bzr internally stores windows drives as uppercase; we'll match that.
checkout_pathC
=
checkout_path
.
replace
(
'c:'
,
'C:'
)
result
=
script
.
run
(
'bzr'
,
'checkout'
,
'-r'
,
'174'
,
local_repo
(
'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'
),
local_repo
(
'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'
,
tmpdir
.
join
(
"cache"
)
),
'django-wikiapp'
)
result
=
script
.
run
(
'python'
,
'setup.py'
,
'develop'
,
cwd
=
script
.
scratch_path
/
'django-wikiapp'
)
...
...
tests/functional/test_install.py
浏览文件 @
f9a3b97b
...
...
@@ -46,18 +46,18 @@ def test_editable_install(script):
assert
not
result
.
files_updated
,
result
.
files_updated
def
test_install_editable_from_svn
(
script
):
def
test_install_editable_from_svn
(
script
,
tmpdir
):
"""
Test checking out from svn.
"""
result
=
script
.
pip
(
'install'
,
'-e'
,
'%s#egg=initools-dev'
%
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
))
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
,
tmpdir
.
join
(
"cache"
)
))
result
.
assert_installed
(
'INITools'
,
with_files
=
[
'.svn'
])
def
test_download_editable_to_custom_path
(
script
):
def
test_download_editable_to_custom_path
(
script
,
tmpdir
):
"""
Test downloading an editable using a relative custom src folder.
"""
...
...
@@ -65,7 +65,7 @@ def test_download_editable_to_custom_path(script):
result
=
script
.
pip
(
'install'
,
'-e'
,
'%s#egg=initools-dev'
%
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
),
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
,
tmpdir
.
join
(
"cache"
)
),
'--src'
,
'customsrc'
,
'--download'
,
...
...
@@ -80,21 +80,21 @@ def test_download_editable_to_custom_path(script):
assert
customdl_files_created
def
test_editable_no_install_followed_by_no_download
(
script
):
def
test_editable_no_install_followed_by_no_download
(
script
,
tmpdir
):
"""
Test installing an editable in two steps (first with --no-install, then with --no-download).
"""
result
=
script
.
pip
(
'install'
,
'-e'
,
'%s#egg=initools-dev'
%
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
),
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
,
tmpdir
.
join
(
"cache"
)
),
'--no-install'
,
expect_error
=
True
)
result
.
assert_installed
(
'INITools'
,
without_egg_link
=
True
,
with_files
=
[
'.svn'
])
result
=
script
.
pip
(
'install'
,
'-e'
,
'%s#egg=initools-dev'
%
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
),
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
,
tmpdir
.
join
(
"cache"
)
),
'--no-download'
,
expect_error
=
True
)
result
.
assert_installed
(
'INITools'
,
without_files
=
[
curdir
,
'.svn'
])
...
...
@@ -140,58 +140,58 @@ def test_install_dev_version_from_pypi(script):
assert
(
script
.
site_packages
/
'initools'
)
in
result
.
files_created
,
str
(
result
.
stdout
)
def
test_install_editable_from_git
(
script
):
def
test_install_editable_from_git
(
script
,
tmpdir
):
"""
Test cloning from Git.
"""
args
=
[
'install'
]
args
.
extend
([
'-e'
,
'%s#egg=pip-test-package'
%
local_checkout
(
'git+http://github.com/pypa/pip-test-package.git'
)])
local_checkout
(
'git+http://github.com/pypa/pip-test-package.git'
,
tmpdir
.
join
(
"cache"
)
)])
result
=
script
.
pip
(
*
args
,
**
{
"expect_error"
:
True
})
result
.
assert_installed
(
'pip-test-package'
,
with_files
=
[
'.git'
])
def
test_install_editable_from_hg
(
script
):
def
test_install_editable_from_hg
(
script
,
tmpdir
):
"""
Test cloning from Mercurial.
"""
result
=
script
.
pip
(
'install'
,
'-e'
,
'%s#egg=ScriptTest'
%
local_checkout
(
'hg+https://bitbucket.org/ianb/scripttest'
),
local_checkout
(
'hg+https://bitbucket.org/ianb/scripttest'
,
tmpdir
.
join
(
"cache"
)
),
expect_error
=
True
)
result
.
assert_installed
(
'ScriptTest'
,
with_files
=
[
'.hg'
])
def
test_vcs_url_final_slash_normalization
(
script
):
def
test_vcs_url_final_slash_normalization
(
script
,
tmpdir
):
"""
Test that presence or absence of final slash in VCS URL is normalized.
"""
result
=
script
.
pip
(
'install'
,
'-e'
,
'%s/#egg=ScriptTest'
%
local_checkout
(
'hg+https://bitbucket.org/ianb/scripttest'
),
local_checkout
(
'hg+https://bitbucket.org/ianb/scripttest'
,
tmpdir
.
join
(
"cache"
)
),
expect_error
=
True
)
assert
'pip-log.txt'
not
in
result
.
files_created
,
result
.
files_created
[
'pip-log.txt'
].
bytes
def
test_install_editable_from_bazaar
(
script
):
def
test_install_editable_from_bazaar
(
script
,
tmpdir
):
"""
Test checking out from Bazaar.
"""
result
=
script
.
pip
(
'install'
,
'-e'
,
'%s/@174#egg=django-wikiapp'
%
local_checkout
(
'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'
),
local_checkout
(
'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'
,
tmpdir
.
join
(
"cache"
)
),
expect_error
=
True
)
result
.
assert_installed
(
'django-wikiapp'
,
with_files
=
[
'.bzr'
])
def
test_vcs_url_urlquote_normalization
(
script
):
def
test_vcs_url_urlquote_normalization
(
script
,
tmpdir
):
"""
Test that urlquoted characters are normalized for repo URL comparison.
"""
result
=
script
.
pip
(
'install'
,
'-e'
,
'%s/#egg=django-wikiapp'
%
local_checkout
(
'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'
),
local_checkout
(
'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'
,
tmpdir
.
join
(
"cache"
)
),
expect_error
=
True
)
assert
'pip-log.txt'
not
in
result
.
files_created
,
result
.
files_created
[
'pip-log.txt'
].
bytes
...
...
@@ -295,7 +295,7 @@ def test_install_with_hacked_egg_info(script):
assert
'Successfully installed hackedegginfo
\n
'
in
result
.
stdout
def
test_install_using_install_option_and_editable
(
script
):
def
test_install_using_install_option_and_editable
(
script
,
tmpdir
):
"""
Test installing a tool using -e and --install-option
"""
...
...
@@ -303,20 +303,20 @@ def test_install_using_install_option_and_editable(script):
script
.
scratch_path
.
join
(
folder
).
mkdir
()
url
=
'git+git://github.com/pypa/virtualenv'
result
=
script
.
pip
(
'install'
,
'-e'
,
'%s#egg=virtualenv'
%
local_checkout
(
url
),
local_checkout
(
url
,
tmpdir
.
join
(
"cache"
)
),
'--install-option=--script-dir=%s'
%
folder
)
virtualenv_bin
=
script
.
venv
/
'src'
/
'virtualenv'
/
folder
/
'virtualenv'
+
script
.
exe
assert
virtualenv_bin
in
result
.
files_created
def
test_install_global_option_using_editable
(
script
):
def
test_install_global_option_using_editable
(
script
,
tmpdir
):
"""
Test using global distutils options, but in an editable installation
"""
url
=
'hg+http://bitbucket.org/runeh/anyjson'
result
=
script
.
pip
(
'install'
,
'--global-option=--version'
,
'-e'
,
'%s@0.2.5#egg=anyjson'
%
local_checkout
(
url
))
local_checkout
(
url
,
tmpdir
.
join
(
"cache"
)
))
assert
'0.2.5
\n
'
in
result
.
stdout
...
...
tests/functional/test_install_cleanup.py
浏览文件 @
f9a3b97b
...
...
@@ -29,7 +29,7 @@ def test_no_clean_option_blocks_cleaning_after_install(script):
assert
exists
(
build
),
"build/simple should still exist %s"
%
str
(
result
)
def
test_cleanup_after_install_editable_from_hg
(
script
):
def
test_cleanup_after_install_editable_from_hg
(
script
,
tmpdir
):
"""
Test clean up after cloning from Mercurial.
...
...
@@ -37,7 +37,7 @@ def test_cleanup_after_install_editable_from_hg(script):
script
.
pip
(
'install'
,
'-e'
,
'%s#egg=ScriptTest'
%
local_checkout
(
'hg+https://bitbucket.org/ianb/scripttest'
),
local_checkout
(
'hg+https://bitbucket.org/ianb/scripttest'
,
tmpdir
.
join
(
"cache"
)
),
expect_error
=
True
)
build
=
script
.
venv_path
/
'build'
src
=
script
.
venv_path
/
'src'
...
...
tests/functional/test_install_index.py
浏览文件 @
f9a3b97b
...
...
@@ -3,7 +3,7 @@ import textwrap
from
pip.backwardcompat
import
urllib
from
tests.lib
import
pyversion
,
tests_data
,
path_to_url
from
tests.lib
import
pyversion
,
tests_data
,
path_to_url
,
packages
def
test_find_links_relative_path
(
script
):
...
...
tests/functional/test_install_reqs.py
浏览文件 @
f9a3b97b
...
...
@@ -59,7 +59,7 @@ def test_relative_requirements_file(script):
assert
(
script
.
site_packages
/
'fspkg'
)
in
result
.
files_created
,
str
(
result
.
stdout
)
def
test_multiple_requirements_files
(
script
):
def
test_multiple_requirements_files
(
script
,
tmpdir
):
"""
Test installing from multiple nested requirements files.
...
...
@@ -67,7 +67,7 @@ def test_multiple_requirements_files(script):
other_lib_name
,
other_lib_version
=
'anyjson'
,
'0.3'
script
.
scratch_path
.
join
(
"initools-req.txt"
).
write
(
textwrap
.
dedent
(
"""
\
-e %s@10#egg=INITools-dev
-r %s-req.txt"""
%
(
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
),
-r %s-req.txt"""
%
(
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
,
tmpdir
.
join
(
"cache"
)
),
other_lib_name
)))
script
.
scratch_path
.
join
(
"%s-req.txt"
%
other_lib_name
).
write
(
textwrap
.
dedent
(
"""
\
%s<=%s
...
...
tests/functional/test_install_upgrade.py
浏览文件 @
f9a3b97b
...
...
@@ -183,10 +183,10 @@ def test_install_with_ignoreinstalled_requested(script):
assert
script
.
site_packages
/
'INITools-0.1-py%s.egg-info'
%
pyversion
not
in
result
.
files_created
def
test_upgrade_vcs_req_with_no_dists_found
(
script
):
def
test_upgrade_vcs_req_with_no_dists_found
(
script
,
tmpdir
):
"""It can upgrade a VCS requirement that has no distributions otherwise."""
req
=
"%s#egg=pip-test-package"
%
local_checkout
(
"git+http://github.com/pypa/pip-test-package.git"
)
"git+http://github.com/pypa/pip-test-package.git"
,
tmpdir
.
join
(
"cache"
)
)
script
.
pip
(
"install"
,
req
)
result
=
script
.
pip
(
"install"
,
"-U"
,
req
)
assert
not
result
.
returncode
...
...
tests/functional/test_install_user.py
浏览文件 @
f9a3b97b
...
...
@@ -52,14 +52,14 @@ class Tests_UserSite:
assert
'INITools'
==
project_name
,
"'%s' should be 'INITools'"
%
project_name
def
test_install_subversion_usersite_editable_with_distribute
(
self
,
script
,
virtualenv
):
def
test_install_subversion_usersite_editable_with_distribute
(
self
,
script
,
virtualenv
,
tmpdir
):
"""
Test installing current directory ('.') into usersite after installing distribute
"""
virtualenv
.
system_site_packages
=
True
result
=
script
.
pip
(
'install'
,
'--user'
,
'-e'
,
'%s#egg=initools-dev'
%
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
))
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
,
tmpdir
.
join
(
"cache"
)
))
result
.
assert_installed
(
'INITools'
,
use_user_site
=
True
)
...
...
tests/functional/test_install_vcs.py
浏览文件 @
f9a3b97b
...
...
@@ -2,13 +2,13 @@ from tests.lib import _create_test_package, _change_test_package_version
from
tests.lib.local_repos
import
local_checkout
def
test_install_editable_from_git_with_https
(
script
):
def
test_install_editable_from_git_with_https
(
script
,
tmpdir
):
"""
Test cloning from Git with https.
"""
result
=
script
.
pip
(
'install'
,
'-e'
,
'%s#egg=pip-test-package'
%
local_checkout
(
'git+https://github.com/pypa/pip-test-package.git'
),
local_checkout
(
'git+https://github.com/pypa/pip-test-package.git'
,
tmpdir
.
join
(
"cache"
)
),
expect_error
=
True
)
result
.
assert_installed
(
'pip-test-package'
,
with_files
=
[
'.git'
])
...
...
@@ -49,59 +49,60 @@ def test_git_with_tag_name_as_revision(script):
assert
'0.1'
in
version
.
stdout
def
test_git_with_tag_name_and_update
(
script
):
def
test_git_with_tag_name_and_update
(
script
,
tmpdir
):
"""
Test cloning a git repository and updating to a different version.
"""
result
=
script
.
pip
(
'install'
,
'-e'
,
'%s#egg=pip-test-package'
%
local_checkout
(
'git+http://github.com/pypa/pip-test-package.git'
),
local_checkout
(
'git+http://github.com/pypa/pip-test-package.git'
,
tmpdir
.
join
(
"cache"
)
),
expect_error
=
True
)
result
.
assert_installed
(
'pip-test-package'
,
with_files
=
[
'.git'
])
result
=
script
.
pip
(
'install'
,
'--global-option=--version'
,
'-e'
,
'%s@0.1.2#egg=pip-test-package'
%
local_checkout
(
'git+http://github.com/pypa/pip-test-package.git'
),
local_checkout
(
'git+http://github.com/pypa/pip-test-package.git'
,
tmpdir
.
join
(
"cache"
)
),
expect_error
=
True
)
assert
'0.1.2'
in
result
.
stdout
def
test_git_branch_should_not_be_changed
(
script
):
def
test_git_branch_should_not_be_changed
(
script
,
tmpdir
):
"""
Editable installations should not change branch
related to issue #32 and #161
"""
script
.
pip
(
'install'
,
'-e'
,
'%s#egg=pip-test-package'
%
local_checkout
(
'git+http://github.com/pypa/pip-test-package.git'
),
local_checkout
(
'git+http://github.com/pypa/pip-test-package.git'
,
tmpdir
.
join
(
"cache"
)
),
expect_error
=
True
)
source_dir
=
script
.
venv_path
/
'src'
/
'pip-test-package'
result
=
script
.
run
(
'git'
,
'branch'
,
cwd
=
source_dir
)
assert
'* master'
in
result
.
stdout
,
result
.
stdout
def
test_git_with_non_editable_unpacking
(
script
):
def
test_git_with_non_editable_unpacking
(
script
,
tmpdir
):
"""
Test cloning a git repository from a non-editable URL with a given tag.
"""
result
=
script
.
pip
(
'install'
,
'--global-option=--version'
,
local_checkout
(
'git+http://github.com/pypa/pip-test-package.git@0.1.2#egg=pip-test-package'
'git+http://github.com/pypa/pip-test-package.git@0.1.2#egg=pip-test-package'
,
tmpdir
.
join
(
"cache"
)
),
expect_error
=
True
)
assert
'0.1.2'
in
result
.
stdout
def
test_git_with_editable_where_egg_contains_dev_string
(
script
):
def
test_git_with_editable_where_egg_contains_dev_string
(
script
,
tmpdir
):
"""
Test cloning a git repository from an editable url which contains "dev" string
"""
result
=
script
.
pip
(
'install'
,
'-e'
,
'%s#egg=django-devserver'
%
local_checkout
(
'git+git://github.com/dcramer/django-devserver.git'
))
local_checkout
(
'git+git://github.com/dcramer/django-devserver.git'
,
tmpdir
.
join
(
"cache"
)
))
result
.
assert_installed
(
'django-devserver'
,
with_files
=
[
'.git'
])
def
test_git_with_non_editable_where_egg_contains_dev_string
(
script
):
def
test_git_with_non_editable_where_egg_contains_dev_string
(
script
,
tmpdir
):
"""
Test cloning a git repository from a non-editable url which contains "dev" string
"""
result
=
script
.
pip
(
'install'
,
'%s#egg=django-devserver'
%
local_checkout
(
'git+git://github.com/dcramer/django-devserver.git'
))
local_checkout
(
'git+git://github.com/dcramer/django-devserver.git'
,
tmpdir
.
join
(
"cache"
)
))
devserver_folder
=
script
.
site_packages
/
'devserver'
assert
devserver_folder
in
result
.
files_created
,
str
(
result
)
...
...
tests/functional/test_uninstall.py
浏览文件 @
f9a3b97b
...
...
@@ -113,40 +113,42 @@ def test_uninstall_easy_installed_console_scripts(script):
assert_all_changes
(
result
,
result2
,
[
script
.
venv
/
'build'
,
'cache'
])
def
test_uninstall_editable_from_svn
(
script
):
def
test_uninstall_editable_from_svn
(
script
,
tmpdir
):
"""
Test uninstalling an editable installation from svn.
"""
result
=
script
.
pip
(
'install'
,
'-e'
,
'%s#egg=initools-dev'
%
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
))
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
,
tmpdir
.
join
(
"cache"
)
))
result
.
assert_installed
(
'INITools'
)
result2
=
script
.
pip
(
'uninstall'
,
'-y'
,
'initools'
)
assert
(
script
.
venv
/
'src'
/
'initools'
in
result2
.
files_after
),
'oh noes, pip deleted my sources!'
assert_all_changes
(
result
,
result2
,
[
script
.
venv
/
'src'
,
script
.
venv
/
'build'
])
def
test_uninstall_editable_with_source_outside_venv
(
script
):
def
test_uninstall_editable_with_source_outside_venv
(
script
,
tmpdir
):
"""
Test uninstalling editable install from existing source outside the venv.
"""
cache_dir
=
tmpdir
.
join
(
"cache"
)
try
:
temp
=
mkdtemp
()
tmpdir
=
join
(
temp
,
'virtualenv'
)
_test_uninstall_editable_with_source_outside_venv
(
script
,
tmpdir
)
_test_uninstall_editable_with_source_outside_venv
(
script
,
tmpdir
,
cache_dir
)
finally
:
rmtree
(
temp
)
def
_test_uninstall_editable_with_source_outside_venv
(
script
,
tmpdir
):
result
=
script
.
run
(
'git'
,
'clone'
,
local_repo
(
'git+git://github.com/pypa/virtualenv'
),
tmpdir
)
def
_test_uninstall_editable_with_source_outside_venv
(
script
,
tmpdir
,
cache_dir
):
result
=
script
.
run
(
'git'
,
'clone'
,
local_repo
(
'git+git://github.com/pypa/virtualenv'
,
cache_dir
),
tmpdir
)
result2
=
script
.
pip
(
'install'
,
'-e'
,
tmpdir
)
assert
(
join
(
script
.
site_packages
,
'virtualenv.egg-link'
)
in
result2
.
files_created
),
list
(
result2
.
files_created
.
keys
())
result3
=
script
.
pip
(
'uninstall'
,
'-y'
,
'virtualenv'
,
expect_error
=
True
)
assert_all_changes
(
result
,
result3
,
[
script
.
venv
/
'build'
])
def
test_uninstall_from_reqs_file
(
script
):
def
test_uninstall_from_reqs_file
(
script
,
tmpdir
):
"""
Test uninstall from a requirements file.
...
...
@@ -155,7 +157,7 @@ def test_uninstall_from_reqs_file(script):
-e %s#egg=initools-dev
# and something else to test out:
PyLogo<0.4
"""
%
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
)))
"""
%
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
,
tmpdir
.
join
(
"cache"
)
)))
result
=
script
.
pip
(
'install'
,
'-r'
,
'test-req.txt'
)
script
.
scratch_path
.
join
(
"test-req.txt"
).
write
(
textwrap
.
dedent
(
"""
\
# -f, -i, and --extra-index-url should all be ignored by uninstall
...
...
@@ -166,7 +168,7 @@ def test_uninstall_from_reqs_file(script):
-e %s#egg=initools-dev
# and something else to test out:
PyLogo<0.4
"""
%
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
)))
"""
%
local_checkout
(
'svn+http://svn.colorstudy.com/INITools/trunk'
,
tmpdir
.
join
(
"cache"
)
)))
result2
=
script
.
pip
(
'uninstall'
,
'-r'
,
'test-req.txt'
,
'-y'
)
assert_all_changes
(
result
,
result2
,
[
script
.
venv
/
'build'
,
script
.
venv
/
'src'
,
script
.
scratch
/
'test-req.txt'
])
...
...
tests/lib/local_repos.py
浏览文件 @
f9a3b97b
...
...
@@ -13,16 +13,13 @@ else:
subprocess_call
=
subprocess
.
call
CACHE_PATH
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
)),
'tests_cache'
)
def
_create_initools_repository
(
directory
):
subprocess_call
(
'svnadmin create INITools'
.
split
(),
cwd
=
directory
)
def
_create_initools_repository
():
subprocess_call
(
'svnadmin create INITools'
.
split
(),
cwd
=
_get_vcs_folder
())
def
_dump_initools_repository
():
def
_dump_initools_repository
(
directory
):
filename
,
_
=
urlretrieve
(
'http://bitbucket.org/hltbra/pip-initools-dump/raw/8b55c908a320/INITools_modified.dump'
)
initools_folder
=
os
.
path
.
join
(
_get_vcs_folder
()
,
'INITools'
)
initools_folder
=
os
.
path
.
join
(
directory
,
'INITools'
)
devnull
=
open
(
os
.
devnull
,
'w'
)
dump
=
open
(
filename
)
subprocess_call
([
'svnadmin'
,
'load'
,
initools_folder
],
stdin
=
dump
,
stdout
=
devnull
)
...
...
@@ -31,21 +28,13 @@ def _dump_initools_repository():
os
.
remove
(
filename
)
def
_create_svn_repository_for_initools
():
tests_cache
=
_get_vcs_folder
()
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
tests_cache
,
'INITools'
)):
_create_initools_repository
()
_dump_initools_repository
()
def
_create_svn_repository_for_initools
(
directory
):
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
directory
,
'INITools'
)):
_create_initools_repository
(
directory
)
_dump_initools_repository
(
directory
)
def
_get_vcs_folder
():
if
not
os
.
path
.
exists
(
CACHE_PATH
):
os
.
mkdir
(
CACHE_PATH
)
return
CACHE_PATH
def
_get_vcs_and_checkout_url
(
remote_repository
):
tests_cache
=
_get_vcs_folder
()
def
_get_vcs_and_checkout_url
(
remote_repository
,
directory
):
vcs_classes
=
{
'svn'
:
subversion
.
Subversion
,
'git'
:
git
.
Git
,
'bzr'
:
bazaar
.
Bazaar
,
...
...
@@ -62,17 +51,21 @@ def _get_vcs_and_checkout_url(remote_repository):
else
:
repository_name
=
os
.
path
.
basename
(
remote_repository
)
destination_path
=
os
.
path
.
join
(
tests_cache
,
repository_name
)
destination_path
=
os
.
path
.
join
(
directory
,
repository_name
)
if
not
os
.
path
.
exists
(
destination_path
):
vcs_class
(
remote_repository
).
obtain
(
destination_path
)
return
'%s+%s'
%
(
vcs
,
path_to_url
(
'/'
.
join
([
tests_cache
,
repository_name
,
branch
])))
return
'%s+%s'
%
(
vcs
,
path_to_url
(
'/'
.
join
([
directory
,
repository_name
,
branch
])))
def
local_checkout
(
remote_repo
,
directory
):
if
not
os
.
path
.
exists
(
directory
):
os
.
mkdir
(
directory
)
#os.makedirs(directory)
def
local_checkout
(
remote_repo
):
if
remote_repo
.
startswith
(
'svn'
):
_create_svn_repository_for_initools
()
return
_get_vcs_and_checkout_url
(
remote_repo
)
_create_svn_repository_for_initools
(
directory
)
return
_get_vcs_and_checkout_url
(
remote_repo
,
directory
)
def
local_repo
(
remote_repo
):
return
local_checkout
(
remote_repo
).
split
(
'+'
,
1
)[
1
]
def
local_repo
(
remote_repo
,
directory
):
return
local_checkout
(
remote_repo
,
directory
).
split
(
'+'
,
1
)[
1
]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录