1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

fix references to req methods/classes after refactor

This commit is contained in:
Marcus Smith 2014-01-12 10:05:11 -08:00
parent d1634a842f
commit a7c522da97
11 changed files with 40 additions and 26 deletions

View file

@ -1,3 +1,7 @@
from req_install import InstallRequirement
from req_set import RequirementSet
from req_set import RequirementSet, Requirements
from req_file import parse_requirements
__all__ = [RequirementSet, Requirements, InstallRequirement,
parse_requirements]

View file

@ -3,6 +3,7 @@ import re
from pip.backwardcompat import urlparse
from pip.download import PipSession, get_file_content
from pip.req.req_install import InstallRequirement
from pip.util import normalize_name
_scheme_re = re.compile(r'^(http|https|file):', re.I)

View file

@ -17,7 +17,8 @@ from pip.locations import bin_py, running_under_virtualenv, PIP_DELETE_MARKER_FI
from pip.log import logger
from pip.util import (display_path, rmtree, ask_path_exists, backup_dir, is_installable_dir,
dist_in_usersite, dist_in_site_packages, egg_link_path, make_path_relative,
call_subprocess, is_prerelease
call_subprocess, is_prerelease, read_text_file, FakeFile, _make_build_dir)
from pip.req.req_uninstall import UninstallPathSet
from pip.vcs import vcs
from pip.wheel import move_wheel_files, Wheel, wheel_ext

View file

@ -9,12 +9,14 @@ from pip.backwardcompat import HTTPError
from pip.download import (PipSession, url_to_path, unpack_vcs_link, is_vcs_url,
is_file_url, unpack_file_url, unpack_http_url)
from pip.exceptions import (InstallationError, BestVersionAlreadyInstalled,
DistributionNotFound, PreviousBuildDirError
DistributionNotFound, PreviousBuildDirError)
from pip.index import Link
from pip.locations import (PIP_DELETE_MARKER_FILENAME, write_delete_marker_file,
build_prefix)
from pip.log import logger
from pip.util import display_path, rmtree, dist_in_usersite, call_subprocess
from pip.req.req_install import InstallRequirement
from pip.util import (display_path, rmtree, dist_in_usersite, call_subprocess,
_make_build_dir)
from pip.vcs import vcs

View file

@ -1,3 +1,4 @@
import locale
import sys
import shutil
import os
@ -12,7 +13,8 @@ import textwrap
from pip.exceptions import InstallationError, BadCommand, PipError
from pip.backwardcompat import(WindowsError, string_types, raw_input,
console_to_str, user_site, PermissionError)
from pip.locations import site_packages, running_under_virtualenv, virtualenv_no_global
from pip.locations import (site_packages, running_under_virtualenv, virtualenv_no_global,
write_delete_marker_file)
from pip.log import logger
from pip._vendor import pkg_resources
from pip._vendor.distlib import version

View file

@ -376,7 +376,7 @@ def uninstallation_paths(dist):
UninstallPathSet.add() takes care of the __pycache__ .pyc.
"""
from pip.req import FakeFile # circular import
from pip.util import FakeFile # circular import
r = csv.reader(FakeFile(dist.get_metadata_lines('RECORD')))
for row in r:
path = os.path.join(dist.location, row[0])

View file

@ -6,7 +6,8 @@ import pytest
from mock import patch
from pip.backwardcompat import urllib
from pip.req import Requirements, parse_editable, parse_requirements
from pip.req import Requirements, parse_requirements
from pip.req.req_install import parse_editable
from tests.lib import (pyversion, path_to_url,
_create_test_package_with_subdirectory)
from tests.lib.local_repos import local_checkout

View file

@ -23,8 +23,8 @@ def _patch_dist_in_site_packages(script):
def dist_in_site_packages(dist):
return False
from pip import req
req.dist_in_site_packages = dist_in_site_packages
from pip.req import req_install
req_install.dist_in_site_packages = dist_in_site_packages
"""))
# Caught py32 with an outdated __pycache__ file after a sitecustomize

View file

@ -192,38 +192,38 @@ def test_uninstall_as_egg(script, data):
assert_all_changes(result, result2, [script.venv/'build', 'cache', script.site_packages/'easy-install.pth'])
@patch('pip.req.logger')
@patch('pip.req.req_uninstall.logger')
def test_uninstallpathset_no_paths(mock_logger):
"""
Test UninstallPathSet logs notification when there are no paths to uninstall
"""
from pip.req import UninstallPathSet
from pip.req.req_uninstall import UninstallPathSet
from pkg_resources import get_distribution
test_dist = get_distribution('pip')
# ensure that the distribution is "local"
with patch("pip.req.dist_is_local") as mock_dist_is_local:
with patch("pip.req.req_uninstall.dist_is_local") as mock_dist_is_local:
mock_dist_is_local.return_value = True
uninstall_set = UninstallPathSet(test_dist)
uninstall_set.remove() #with no files added to set
mock_logger.notify.assert_any_call("Can't uninstall 'pip'. No files were found to uninstall.")
@patch('pip.req.logger')
@patch('pip.req.req_uninstall.logger')
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 pip.req.req_uninstall import UninstallPathSet
from pkg_resources import get_distribution
test_dist = get_distribution('pip')
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
with patch("pip.req.dist_is_local") as mock_dist_is_local:
with patch("pip.req.req_uninstall.dist_is_local") as mock_dist_is_local:
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

View file

@ -56,11 +56,12 @@ class VirtualEnvironment(object):
p = subprocess.Popen(
cmd,
cwd=self.pip_source_dir,
stderr=subprocess.STDOUT,
stdout=DEVNULL,
#stderr=subprocess.STDOUT,
#stdout=DEVNULL,
)
p.communicate()
if p.returncode != 0:
raise Exception(p.stderr)
raise subprocess.CalledProcessError(p.returncode, cmd[0],
output=p.stdout,
)

View file

@ -11,8 +11,10 @@ from mock import Mock, patch, mock_open
from pip.exceptions import PreviousBuildDirError, InvalidWheelFilename, UnsupportedWheel
from pip.index import PackageFinder
from pip.log import logger
from pip.req import (read_text_file, InstallRequirement, RequirementSet,
parse_editable, Requirements, parse_requirements)
from pip.req import (InstallRequirement, RequirementSet,
Requirements, parse_requirements)
from pip.req.req_install import parse_editable
from pip.util import read_text_file
from tests.lib import assert_raises_regexp
@ -62,7 +64,7 @@ def test_egg_info_data(file_contents, expected):
om = mock_open(read_data=file_contents)
em = Mock()
em.return_value = 'cp1252'
with patch('pip.req.open', om, create=True):
with patch('pip.util.open', om, create=True):
with patch('locale.getpreferredencoding', em):
ret = read_text_file('foo')
assert ret == expected.decode('utf-8')
@ -112,9 +114,9 @@ def test_requirements_data_structure_implements__contains__():
assert 'nose' not in requirements
@patch('os.path.normcase')
@patch('pip.req.os.getcwd')
@patch('pip.req.os.path.exists')
@patch('pip.req.os.path.isdir')
@patch('pip.req.req_install.os.getcwd')
@patch('pip.req.req_install.os.path.exists')
@patch('pip.req.req_install.os.path.isdir')
def test_parse_editable_local(isdir_mock, exists_mock, getcwd_mock, normcase_mock):
exists_mock.return_value = isdir_mock.return_value = True
# mocks needed to support path operations on windows tests
@ -139,9 +141,9 @@ def test_parse_editable_vcs_extras():
{'egg': 'foo[extras]'})
@patch('os.path.normcase')
@patch('pip.req.os.getcwd')
@patch('pip.req.os.path.exists')
@patch('pip.req.os.path.isdir')
@patch('pip.req.req_install.os.getcwd')
@patch('pip.req.req_install.os.path.exists')
@patch('pip.req.req_install.os.path.isdir')
def test_parse_editable_local_extras(isdir_mock, exists_mock, getcwd_mock, normcase_mock):
exists_mock.return_value = isdir_mock.return_value = True
normcase_mock.return_value = getcwd_mock.return_value = "/some/path"