Skip to content

Commit a7c522d

Browse files
committed
fix references to req methods/classes after refactor
1 parent d1634a8 commit a7c522d

11 files changed

+40
-26
lines changed

pip/req/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11

22
from req_install import InstallRequirement
3-
from req_set import RequirementSet
3+
from req_set import RequirementSet, Requirements
4+
from req_file import parse_requirements
5+
6+
__all__ = [RequirementSet, Requirements, InstallRequirement,
7+
parse_requirements]

pip/req/req_file.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from pip.backwardcompat import urlparse
55
from pip.download import PipSession, get_file_content
6+
from pip.req.req_install import InstallRequirement
67
from pip.util import normalize_name
78

89
_scheme_re = re.compile(r'^(http|https|file):', re.I)

pip/req/req_install.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
from pip.log import logger
1818
from pip.util import (display_path, rmtree, ask_path_exists, backup_dir, is_installable_dir,
1919
dist_in_usersite, dist_in_site_packages, egg_link_path, make_path_relative,
20-
call_subprocess, is_prerelease
20+
call_subprocess, is_prerelease, read_text_file, FakeFile, _make_build_dir)
21+
from pip.req.req_uninstall import UninstallPathSet
2122
from pip.vcs import vcs
2223
from pip.wheel import move_wheel_files, Wheel, wheel_ext
2324

pip/req/req_set.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
from pip.download import (PipSession, url_to_path, unpack_vcs_link, is_vcs_url,
1010
is_file_url, unpack_file_url, unpack_http_url)
1111
from pip.exceptions import (InstallationError, BestVersionAlreadyInstalled,
12-
DistributionNotFound, PreviousBuildDirError
12+
DistributionNotFound, PreviousBuildDirError)
1313
from pip.index import Link
1414
from pip.locations import (PIP_DELETE_MARKER_FILENAME, write_delete_marker_file,
1515
build_prefix)
1616
from pip.log import logger
17-
from pip.util import display_path, rmtree, dist_in_usersite, call_subprocess
17+
from pip.req.req_install import InstallRequirement
18+
from pip.util import (display_path, rmtree, dist_in_usersite, call_subprocess,
19+
_make_build_dir)
1820
from pip.vcs import vcs
1921

2022

pip/util.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import locale
12
import sys
23
import shutil
34
import os
@@ -12,7 +13,8 @@
1213
from pip.exceptions import InstallationError, BadCommand, PipError
1314
from pip.backwardcompat import(WindowsError, string_types, raw_input,
1415
console_to_str, user_site, PermissionError)
15-
from pip.locations import site_packages, running_under_virtualenv, virtualenv_no_global
16+
from pip.locations import (site_packages, running_under_virtualenv, virtualenv_no_global,
17+
write_delete_marker_file)
1618
from pip.log import logger
1719
from pip._vendor import pkg_resources
1820
from pip._vendor.distlib import version

pip/wheel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def uninstallation_paths(dist):
376376
377377
UninstallPathSet.add() takes care of the __pycache__ .pyc.
378378
"""
379-
from pip.req import FakeFile # circular import
379+
from pip.util import FakeFile # circular import
380380
r = csv.reader(FakeFile(dist.get_metadata_lines('RECORD')))
381381
for row in r:
382382
path = os.path.join(dist.location, row[0])

tests/functional/test_install_reqs.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from mock import patch
77

88
from pip.backwardcompat import urllib
9-
from pip.req import Requirements, parse_editable, parse_requirements
9+
from pip.req import Requirements, parse_requirements
10+
from pip.req.req_install import parse_editable
1011
from tests.lib import (pyversion, path_to_url,
1112
_create_test_package_with_subdirectory)
1213
from tests.lib.local_repos import local_checkout

tests/functional/test_install_user.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def _patch_dist_in_site_packages(script):
2323
def dist_in_site_packages(dist):
2424
return False
2525
26-
from pip import req
27-
req.dist_in_site_packages = dist_in_site_packages
26+
from pip.req import req_install
27+
req_install.dist_in_site_packages = dist_in_site_packages
2828
"""))
2929

3030
# Caught py32 with an outdated __pycache__ file after a sitecustomize

tests/functional/test_uninstall.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -192,38 +192,38 @@ def test_uninstall_as_egg(script, data):
192192
assert_all_changes(result, result2, [script.venv/'build', 'cache', script.site_packages/'easy-install.pth'])
193193

194194

195-
@patch('pip.req.logger')
195+
@patch('pip.req.req_uninstall.logger')
196196
def test_uninstallpathset_no_paths(mock_logger):
197197
"""
198198
Test UninstallPathSet logs notification when there are no paths to uninstall
199199
200200
"""
201-
from pip.req import UninstallPathSet
201+
from pip.req.req_uninstall import UninstallPathSet
202202
from pkg_resources import get_distribution
203203
test_dist = get_distribution('pip')
204204
# ensure that the distribution is "local"
205-
with patch("pip.req.dist_is_local") as mock_dist_is_local:
205+
with patch("pip.req.req_uninstall.dist_is_local") as mock_dist_is_local:
206206
mock_dist_is_local.return_value = True
207207
uninstall_set = UninstallPathSet(test_dist)
208208
uninstall_set.remove() #with no files added to set
209209
mock_logger.notify.assert_any_call("Can't uninstall 'pip'. No files were found to uninstall.")
210210

211211

212-
@patch('pip.req.logger')
212+
@patch('pip.req.req_uninstall.logger')
213213
def test_uninstallpathset_non_local(mock_logger):
214214
"""
215215
Test UninstallPathSet logs notification and returns (with no exception) when dist is non-local
216216
217217
"""
218218
nonlocal_path = os.path.abspath("/nonlocal")
219-
from pip.req import UninstallPathSet
219+
from pip.req.req_uninstall import UninstallPathSet
220220
from pkg_resources import get_distribution
221221
test_dist = get_distribution('pip')
222222
test_dist.location = nonlocal_path
223223
# ensure that the distribution is "non-local"
224224
# setting location isn't enough, due to egg-link file checking for
225225
# develop-installs
226-
with patch("pip.req.dist_is_local") as mock_dist_is_local:
226+
with patch("pip.req.req_uninstall.dist_is_local") as mock_dist_is_local:
227227
mock_dist_is_local.return_value = False
228228
uninstall_set = UninstallPathSet(test_dist)
229229
uninstall_set.remove() #with no files added to set; which is the case when trying to remove non-local dists

tests/lib/venv.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ def _create(self, clear=False):
5656
p = subprocess.Popen(
5757
cmd,
5858
cwd=self.pip_source_dir,
59-
stderr=subprocess.STDOUT,
60-
stdout=DEVNULL,
59+
#stderr=subprocess.STDOUT,
60+
#stdout=DEVNULL,
6161
)
6262
p.communicate()
6363
if p.returncode != 0:
64+
raise Exception(p.stderr)
6465
raise subprocess.CalledProcessError(p.returncode, cmd[0],
6566
output=p.stdout,
6667
)

tests/unit/test_req.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
from pip.exceptions import PreviousBuildDirError, InvalidWheelFilename, UnsupportedWheel
1212
from pip.index import PackageFinder
1313
from pip.log import logger
14-
from pip.req import (read_text_file, InstallRequirement, RequirementSet,
15-
parse_editable, Requirements, parse_requirements)
14+
from pip.req import (InstallRequirement, RequirementSet,
15+
Requirements, parse_requirements)
16+
from pip.req.req_install import parse_editable
17+
from pip.util import read_text_file
1618
from tests.lib import assert_raises_regexp
1719

1820

@@ -62,7 +64,7 @@ def test_egg_info_data(file_contents, expected):
6264
om = mock_open(read_data=file_contents)
6365
em = Mock()
6466
em.return_value = 'cp1252'
65-
with patch('pip.req.open', om, create=True):
67+
with patch('pip.util.open', om, create=True):
6668
with patch('locale.getpreferredencoding', em):
6769
ret = read_text_file('foo')
6870
assert ret == expected.decode('utf-8')
@@ -112,9 +114,9 @@ def test_requirements_data_structure_implements__contains__():
112114
assert 'nose' not in requirements
113115

114116
@patch('os.path.normcase')
115-
@patch('pip.req.os.getcwd')
116-
@patch('pip.req.os.path.exists')
117-
@patch('pip.req.os.path.isdir')
117+
@patch('pip.req.req_install.os.getcwd')
118+
@patch('pip.req.req_install.os.path.exists')
119+
@patch('pip.req.req_install.os.path.isdir')
118120
def test_parse_editable_local(isdir_mock, exists_mock, getcwd_mock, normcase_mock):
119121
exists_mock.return_value = isdir_mock.return_value = True
120122
# mocks needed to support path operations on windows tests
@@ -139,9 +141,9 @@ def test_parse_editable_vcs_extras():
139141
{'egg': 'foo[extras]'})
140142

141143
@patch('os.path.normcase')
142-
@patch('pip.req.os.getcwd')
143-
@patch('pip.req.os.path.exists')
144-
@patch('pip.req.os.path.isdir')
144+
@patch('pip.req.req_install.os.getcwd')
145+
@patch('pip.req.req_install.os.path.exists')
146+
@patch('pip.req.req_install.os.path.isdir')
145147
def test_parse_editable_local_extras(isdir_mock, exists_mock, getcwd_mock, normcase_mock):
146148
exists_mock.return_value = isdir_mock.return_value = True
147149
normcase_mock.return_value = getcwd_mock.return_value = "/some/path"

0 commit comments

Comments
 (0)