mirror of https://github.com/pypa/pip
windows test fixes
This commit is contained in:
parent
0e7c239cfb
commit
6b5fd90af9
|
@ -1,13 +1,29 @@
|
|||
import os
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
|
||||
def path_to_url(path):
|
||||
"""
|
||||
Convert a path to URI. The path will be made absolute and
|
||||
will not have quoted path parts.
|
||||
"""
|
||||
path = os.path.normpath(os.path.abspath(path))
|
||||
drive, path = os.path.splitdrive(path)
|
||||
filepath = path.split(os.path.sep)
|
||||
url = '/'.join(filepath)
|
||||
if drive:
|
||||
return 'file:///' + drive + url
|
||||
return 'file://' +url
|
||||
|
||||
|
||||
HERE = os.path.dirname(__file__)
|
||||
INDEX = "file://" + os.path.join(HERE, '..', '..', 'indexes', 'simple', 'simple')
|
||||
DEP_PATH = os.path.join(HERE, '..', '..', 'indexes', 'simple', 'simple')
|
||||
DEP_URL = path_to_url(DEP_PATH)
|
||||
|
||||
setup(
|
||||
name='LocalExtras',
|
||||
version='0.0.1',
|
||||
packages=find_packages(),
|
||||
extras_require={ 'bar': ['simple'] },
|
||||
dependency_links=[INDEX]
|
||||
dependency_links=[DEP_URL]
|
||||
)
|
||||
|
|
|
@ -497,8 +497,8 @@ def test_install_package_with_root():
|
|||
"""
|
||||
env = reset_env()
|
||||
root_dir = env.scratch_path/'root'
|
||||
result = run_pip('install', '--root', root_dir, '--install-option=--home=',
|
||||
'--install-option=--install-lib=/lib/python', "initools==0.1")
|
||||
result = run_pip('install', '--root', root_dir, "--install-option=--home=''",
|
||||
'--install-option=--install-lib=lib/python', "initools==0.1")
|
||||
|
||||
assert Path('scratch')/'root'/'lib'/'python'/'initools' in result.files_created, str(result)
|
||||
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
import os
|
||||
from pkg_resources import parse_version
|
||||
from pip.backwardcompat import urllib
|
||||
from pip.req import InstallRequirement
|
||||
from pip.index import PackageFinder
|
||||
from pip.exceptions import BestVersionAlreadyInstalled
|
||||
from tests.path import Path
|
||||
from tests.test_pip import here
|
||||
from tests.test_pip import here, path_to_url
|
||||
from nose.tools import assert_raises
|
||||
from mock import Mock
|
||||
|
||||
find_links = 'file://' + urllib.quote(str(Path(here).abspath/'packages').replace('\\', '/'))
|
||||
find_links2 = 'file://' + urllib.quote(str(Path(here).abspath/'packages2').replace('\\', '/'))
|
||||
find_links = path_to_url(os.path.join(here, 'packages'))
|
||||
find_links2 = path_to_url(os.path.join(here, 'packages2'))
|
||||
|
||||
|
||||
def test_no_mpkg():
|
||||
|
|
|
@ -60,7 +60,12 @@ def test_freeze_basic():
|
|||
|
||||
|
||||
def test_freeze_svn():
|
||||
"""Now lets try it with an svn checkout"""
|
||||
"""Test freezing a svn checkout"""
|
||||
|
||||
checkout_path = local_checkout('svn+http://svn.colorstudy.com/INITools/trunk')
|
||||
#svn internally stores windows drives as uppercase; we'll match that.
|
||||
checkout_path = checkout_path.replace('c:', 'C:')
|
||||
|
||||
env = reset_env()
|
||||
result = env.run('svn', 'co', '-r10',
|
||||
local_repo('svn+http://svn.colorstudy.com/INITools/trunk'),
|
||||
|
@ -72,7 +77,7 @@ def test_freeze_svn():
|
|||
Script result: ...pip freeze
|
||||
-- stdout: --------------------
|
||||
-e %s@10#egg=INITools-0.3.1dev...-dev_r10
|
||||
...""" % local_checkout('svn+http://svn.colorstudy.com/INITools/trunk'))
|
||||
...""" % checkout_path)
|
||||
_check_output(result, expected)
|
||||
|
||||
|
||||
|
@ -145,6 +150,11 @@ def test_freeze_bazaar_clone():
|
|||
Test freezing a Bazaar clone.
|
||||
|
||||
"""
|
||||
|
||||
checkout_path = local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1')
|
||||
#bzr internally stores windows drives as uppercase; we'll match that.
|
||||
checkout_pathC = checkout_path.replace('c:', 'C:')
|
||||
|
||||
reset_env()
|
||||
env = get_env()
|
||||
result = env.run('bzr', 'checkout', '-r', '174',
|
||||
|
@ -157,20 +167,18 @@ def test_freeze_bazaar_clone():
|
|||
Script result: ...pip freeze
|
||||
-- stdout: --------------------
|
||||
...-e %s@...#egg=django_wikiapp-...
|
||||
...""" % local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'))
|
||||
...""" % checkout_pathC)
|
||||
_check_output(result, expected)
|
||||
|
||||
result = run_pip('freeze', '-f',
|
||||
'%s/#egg=django-wikiapp' %
|
||||
local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1'),
|
||||
'%s/#egg=django-wikiapp' % checkout_path,
|
||||
expect_stderr=True)
|
||||
expected = textwrap.dedent("""\
|
||||
Script result: ...pip freeze -f %(repo)s/#egg=django-wikiapp
|
||||
-- stdout: --------------------
|
||||
-f %(repo)s/#egg=django-wikiapp
|
||||
...-e %(repo)s@...#egg=django_wikiapp-...
|
||||
...""" % {'repo':
|
||||
local_checkout('bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1')})
|
||||
...-e %(repoC)s@...#egg=django_wikiapp-...
|
||||
...""" % {'repoC': checkout_pathC, 'repo': checkout_path})
|
||||
_check_output(result, expected)
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ from pip.backwardcompat import urllib
|
|||
from tests.path import Path
|
||||
from pip.index import package_to_requirement, HTMLPage, get_mirrors, DEFAULT_MIRROR_HOSTNAME
|
||||
from pip.index import PackageFinder, Link, InfLink
|
||||
from tests.test_pip import reset_env, run_pip, pyversion, here
|
||||
from tests.test_pip import reset_env, run_pip, pyversion, here, path_to_url
|
||||
from string import ascii_lowercase
|
||||
from mock import patch
|
||||
|
||||
|
@ -87,7 +87,7 @@ def test_sort_locations_file_find_link():
|
|||
"""
|
||||
Test that a file:// find-link dir gets listdir run
|
||||
"""
|
||||
find_links_url = 'file://' + os.path.join(here, 'packages')
|
||||
find_links_url = path_to_url(os.path.join(here, 'packages'))
|
||||
find_links = [find_links_url]
|
||||
finder = PackageFinder(find_links, [])
|
||||
files, urls = finder._sort_locations(find_links)
|
||||
|
@ -98,7 +98,7 @@ def test_sort_locations_file_not_find_link():
|
|||
"""
|
||||
Test that a file:// url dir that's not a find-link, doesn't get a listdir run
|
||||
"""
|
||||
index_url = 'file://' + os.path.join(here, 'indexes', 'empty_with_pkg')
|
||||
index_url = path_to_url(os.path.join(here, 'indexes', 'empty_with_pkg'))
|
||||
finder = PackageFinder([], [])
|
||||
files, urls = finder._sort_locations([index_url])
|
||||
assert urls and not files, "urls, but not files should have been found"
|
||||
|
@ -109,7 +109,7 @@ def test_install_from_file_index_hash_link():
|
|||
Test that a pkg can be installed from a file:// index using a link with a hash
|
||||
"""
|
||||
env = reset_env()
|
||||
index_url = 'file://' + os.path.join(here, 'indexes', 'simple')
|
||||
index_url = path_to_url(os.path.join(here, 'indexes', 'simple'))
|
||||
result = run_pip('install', '-i', index_url, 'simple==1.0')
|
||||
egg_info_folder = env.site_packages / 'simple-1.0-py%s.egg-info' % pyversion
|
||||
assert egg_info_folder in result.files_created, str(result)
|
||||
|
@ -119,7 +119,7 @@ def test_file_index_url_quoting():
|
|||
"""
|
||||
Test url quoting of file index url with a space
|
||||
"""
|
||||
index_url = 'file://' + urllib.quote(str(Path(here).abspath/'indexes'/'in dex').replace('\\', '/'))
|
||||
index_url = path_to_url(os.path.join(here, 'indexes', urllib.quote('in dex')))
|
||||
env = reset_env()
|
||||
result = run_pip('install', '-vvv', '--index-url', index_url, 'simple', expect_error=False)
|
||||
assert (env.site_packages/'simple') in result.files_created, str(result.stdout)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import re
|
||||
import textwrap
|
||||
from tests.test_pip import pyversion, reset_env, run_pip, write_file
|
||||
|
@ -77,5 +78,5 @@ def test_editables_flag():
|
|||
result = run_pip('install', '-e', 'git+https://github.com/pypa/pip-test-package.git#egg=pip-test-package')
|
||||
result = run_pip('list', '--editable')
|
||||
assert 'mock (0.7.0)' not in result.stdout, str(result)
|
||||
assert 'src/pip-test-package' in result.stdout, str(result)
|
||||
assert os.path.join('src', 'pip-test-package') in result.stdout, str(result)
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ src_folder = here.folder
|
|||
download_cache = tempfile.mkdtemp(prefix='pip-test-cache')
|
||||
site_packages_suffix = site.USER_SITE[len(site.USER_BASE) + 1:]
|
||||
|
||||
|
||||
def path_to_url(path):
|
||||
"""
|
||||
Convert a path to URI. The path will be made absolute and
|
||||
|
|
|
@ -181,9 +181,9 @@ def test_install_local_editable_with_extras():
|
|||
env = reset_env()
|
||||
to_install = os.path.abspath(os.path.join(here, 'packages', 'LocalExtras'))
|
||||
res = run_pip('install', '-e', to_install + '[bar]', expect_error=False)
|
||||
assert env.site_packages/'easy-install.pth' in res.files_updated
|
||||
assert env.site_packages/'LocalExtras.egg-link' in res.files_created
|
||||
assert env.site_packages/'simple' in res.files_created
|
||||
assert env.site_packages/'easy-install.pth' in res.files_updated, str(result)
|
||||
assert env.site_packages/'LocalExtras.egg-link' in res.files_created, str(result)
|
||||
assert env.site_packages/'simple' in res.files_created, str(result)
|
||||
|
||||
|
||||
def test_url_req_case_mismatch():
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import with_statement
|
||||
|
||||
import textwrap
|
||||
import os
|
||||
import sys
|
||||
from os.path import join, abspath, normpath
|
||||
from tempfile import mkdtemp
|
||||
|
@ -224,10 +225,11 @@ def test_uninstallpathset_non_local(mock_logger):
|
|||
Test UninstallPathSet logs notification and returns (with no exception) when dist is non-local
|
||||
|
||||
"""
|
||||
nonlocal_path = os.path.abspath("/nonlocal")
|
||||
from pip.req import UninstallPathSet
|
||||
from pkg_resources import get_distribution
|
||||
test_dist = get_distribution('pip')
|
||||
test_dist.location = "/NON_LOCAL"
|
||||
test_dist.location = nonlocal_path
|
||||
# ensure that the distribution is "non-local"
|
||||
# setting location isn't enough, due to egg-link file checking for
|
||||
# develop-installs
|
||||
|
@ -235,7 +237,7 @@ def test_uninstallpathset_non_local(mock_logger):
|
|||
mock_dist_is_local.return_value = False
|
||||
uninstall_set = UninstallPathSet(test_dist)
|
||||
uninstall_set.remove() #with no files added to set; which is the case when trying to remove non-local dists
|
||||
mock_logger.notify.assert_any_call("Not uninstalling pip at /NON_LOCAL, outside environment %s" % sys.prefix)
|
||||
mock_logger.notify.assert_any_call("Not uninstalling pip at %s, outside environment %s" % (nonlocal_path, sys.prefix)), mock_logger.notify.mock_calls
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import os
|
||||
import textwrap
|
||||
from os.path import join
|
||||
from nose.tools import nottest
|
||||
from tests.test_pip import (here, reset_env, run_pip, assert_all_changes,
|
||||
write_file, pyversion, _create_test_package,
|
||||
_change_test_package_version)
|
||||
_change_test_package_version, path_to_url)
|
||||
from tests.local_repos import local_checkout
|
||||
|
||||
|
||||
|
@ -49,7 +50,7 @@ def test_upgrade_with_newest_already_installed():
|
|||
not be reinstalled and the user should be informed.
|
||||
"""
|
||||
|
||||
find_links = 'file://' + join(here, 'packages')
|
||||
find_links = path_to_url(os.path.join(here, 'packages'))
|
||||
env = reset_env()
|
||||
run_pip('install', '-f', find_links, '--no-index', 'simple')
|
||||
result = run_pip('install', '--upgrade', '-f', find_links, '--no-index', 'simple')
|
||||
|
@ -144,7 +145,7 @@ def test_uninstall_rollback():
|
|||
|
||||
"""
|
||||
env = reset_env()
|
||||
find_links = 'file://' + join(here, 'packages')
|
||||
find_links = path_to_url(os.path.join(here, 'packages'))
|
||||
result = run_pip('install', '-f', find_links, '--no-index', 'broken==0.1')
|
||||
assert env.site_packages / 'broken.py' in result.files_created, list(result.files_created.keys())
|
||||
result2 = run_pip('install', '-f', find_links, '--no-index', 'broken==0.2broken', expect_error=True)
|
||||
|
|
Loading…
Reference in New Issue