4 changes: 2 additions & 2 deletions tests/unit/test_appdirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pretend

from pip.utils import appdirs
from pip._internal.utils import appdirs


class TestUserCacheDir:
Expand Down Expand Up @@ -80,7 +80,7 @@ def my_get_win_folder(csidl_name):
assert result_is_str, "user_cache_dir did not return a str"

# Test against regression #3463
from pip import create_main_parser
from pip._internal import create_main_parser
create_main_parser().print_help() # This should not crash


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_basecommand.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from pip.basecommand import Command
from pip._internal.basecommand import Command


class FakeCommand(Command):
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pip.cache import WheelCache
from pip.compat import expanduser
from pip._internal.cache import WheelCache
from pip._internal.compat import expanduser


class TestWheelCache:
Expand Down
15 changes: 7 additions & 8 deletions tests/unit/test_cmdoptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pip
from pip import cmdoptions
from pip.basecommand import Command
from pip._internal import cmdoptions, index
from pip._internal.basecommand import Command


class SimpleCommand(Command):
Expand All @@ -19,21 +18,21 @@ def run(self, options, args):
def test_no_binary_overrides():
cmd = SimpleCommand()
cmd.main(['fake', '--only-binary=:all:', '--no-binary=fred'])
expected = pip.index.FormatControl(set(['fred']), set([':all:']))
expected = index.FormatControl(set(['fred']), set([':all:']))
assert cmd.options.format_control == expected


def test_only_binary_overrides():
cmd = SimpleCommand()
cmd.main(['fake', '--no-binary=:all:', '--only-binary=fred'])
expected = pip.index.FormatControl(set([':all:']), set(['fred']))
expected = index.FormatControl(set([':all:']), set(['fred']))
assert cmd.options.format_control == expected


def test_none_resets():
cmd = SimpleCommand()
cmd.main(['fake', '--no-binary=:all:', '--no-binary=:none:'])
expected = pip.index.FormatControl(set([]), set([]))
expected = index.FormatControl(set([]), set([]))
assert cmd.options.format_control == expected


Expand All @@ -42,12 +41,12 @@ def test_none_preserves_other_side():
cmd.main(
['fake', '--no-binary=:all:', '--only-binary=fred',
'--no-binary=:none:'])
expected = pip.index.FormatControl(set([]), set(['fred']))
expected = index.FormatControl(set([]), set(['fred']))
assert cmd.options.format_control == expected


def test_comma_separated_values():
cmd = SimpleCommand()
cmd.main(['fake', '--no-binary=1,2,3'])
expected = pip.index.FormatControl(set(['1', '2', '3']), set([]))
expected = index.FormatControl(set(['1', '2', '3']), set([]))
assert cmd.options.format_control == expected
8 changes: 5 additions & 3 deletions tests/unit/test_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

import pytest

import pip.compat
from pip.compat import console_to_str, expanduser, get_path_uid, native_str
import pip._internal.compat
from pip._internal.compat import (
console_to_str, expanduser, get_path_uid, native_str
)


def test_get_path_uid():
Expand Down Expand Up @@ -62,7 +64,7 @@ def check_warning(msg):
"Subprocess output does not appear to be encoded as")

monkeypatch.setattr(locale, 'getpreferredencoding', lambda: 'utf-8')
monkeypatch.setattr(pip.compat.logger, 'warning', check_warning)
monkeypatch.setattr(pip._internal.compat.logger, 'warning', check_warning)
console_to_str(some_bytes)


Expand Down
6 changes: 4 additions & 2 deletions tests/unit/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import pytest
from mock import MagicMock

from pip.exceptions import ConfigurationError
from pip.locations import new_config_file, site_config_files, venv_config_file
from pip._internal.exceptions import ConfigurationError
from pip._internal.locations import (
new_config_file, site_config_files, venv_config_file
)
from tests.lib.configuration_helpers import ConfigurationMixin, kinds


Expand Down
14 changes: 7 additions & 7 deletions tests/unit/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
from pip._vendor.six.moves.urllib import request as urllib_request

import pip
from pip.download import (
from pip._internal.download import (
MultiDomainBasicAuth, PipSession, SafeFileCache, path_to_url,
unpack_file_url, unpack_http_url, url_to_path
)
from pip.exceptions import HashMismatch
from pip.index import Link
from pip.utils.hashes import Hashes
from pip._internal.exceptions import HashMismatch
from pip._internal.index import Link
from pip._internal.utils.hashes import Hashes
from tests.lib import create_file


Expand Down Expand Up @@ -75,7 +75,7 @@ def raise_for_status(self):
pass


@patch('pip.download.unpack_file')
@patch('pip._internal.download.unpack_file')
def test_unpack_http_url_bad_downloaded_checksum(mock_unpack_file):
"""
If already-downloaded file has bad checksum, re-download.
Expand Down Expand Up @@ -255,8 +255,8 @@ def test_unpack_file_url_thats_a_dir(self, tmpdir, data):
class TestSafeFileCache:
"""
The no_perms test are useless on Windows since SafeFileCache uses
pip.utils.filesystem.check_path_owner which is based on os.geteuid
which is absent on Windows.
pip._internal.utils.filesystem.check_path_owner which is based on
os.geteuid which is absent on Windows.
"""

def test_cache_roundtrip(self, tmpdir):
Expand Down
32 changes: 17 additions & 15 deletions tests/unit/test_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
from mock import Mock, patch
from pkg_resources import Distribution, parse_version

import pip.pep425tags
import pip.wheel
from pip.download import PipSession
from pip.exceptions import BestVersionAlreadyInstalled, DistributionNotFound
from pip.index import (
import pip._internal.pep425tags
import pip._internal.wheel
from pip._internal.download import PipSession
from pip._internal.exceptions import (
BestVersionAlreadyInstalled, DistributionNotFound
)
from pip._internal.index import (
FormatControl, InstallationCandidate, Link, PackageFinder, fmt_ctl_formats
)
from pip.req import InstallRequirement
from pip._internal.req import InstallRequirement


def test_no_mpkg(data):
Expand All @@ -35,7 +37,7 @@ def test_no_partial_name_match(data):
def test_tilde(data):
"""Finder can accept a path with ~ in it and will normalize it."""
session = PipSession()
with patch('pip.index.os.path.exists', return_value=True):
with patch('pip._internal.index.os.path.exists', return_value=True):
finder = PackageFinder(['~/python-pkgs'], [], session=session)
req = InstallRequirement.from_line("gmpy")
with pytest.raises(DistributionNotFound):
Expand Down Expand Up @@ -138,9 +140,9 @@ def test_not_find_wheel_not_supported(self, data, monkeypatch):
Test not finding an unsupported wheel.
"""
monkeypatch.setattr(
pip.pep425tags,
"supported_tags",
[('py1', 'none', 'any')],
pip._internal.pep425tags,
"get_supported",
lambda **kw: [("py1", "none", "any")],
)

req = InstallRequirement.from_line("simple.dist")
Expand All @@ -149,7 +151,7 @@ def test_not_find_wheel_not_supported(self, data, monkeypatch):
[],
session=PipSession(),
)
finder.valid_tags = pip.pep425tags.supported_tags
finder.valid_tags = pip._internal.pep425tags.get_supported()

with pytest.raises(DistributionNotFound):
finder.find_requirement(req, True)
Expand All @@ -159,9 +161,9 @@ def test_find_wheel_supported(self, data, monkeypatch):
Test finding supported wheel.
"""
monkeypatch.setattr(
pip.pep425tags,
"supported_tags",
[('py2', 'none', 'any')],
pip._internal.pep425tags,
"get_supported",
lambda **kw: [('py2', 'none', 'any')],
)

req = InstallRequirement.from_line("simple.dist")
Expand Down Expand Up @@ -497,7 +499,7 @@ class test_link_package_versions(object):

# patch this for travis which has distribute in its base env for now
@patch(
'pip.wheel.pkg_resources.get_distribution',
'pip._internal.wheel.pkg_resources.get_distribution',
lambda x: Distribution(project_name='setuptools', version='0.9')
)
def setup(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest

from pip.download import PipSession
from pip.index import HTMLPage, Link, PackageFinder
from pip._internal.download import PipSession
from pip._internal.index import HTMLPage, Link, PackageFinder


def test_sort_locations_file_expand_dir(data):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from mock import Mock

from pip.locations import distutils_scheme
from pip._internal.locations import distutils_scheme

if sys.platform == 'win32':
pwd = Mock()
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest

import pip.configuration
from pip import main
import pip._internal.configuration
from pip._internal import main
from tests.lib.options_helpers import AddFakeCommandMixin


Expand Down Expand Up @@ -188,18 +188,18 @@ class TestOptionsConfigFiles(object):
def test_venv_config_file_found(self, monkeypatch):
# strict limit on the site_config_files list
monkeypatch.setattr(
pip.configuration, 'site_config_files', ['/a/place']
pip._internal.configuration, 'site_config_files', ['/a/place']
)

# If we are running in a virtualenv and all files appear to exist,
# we should see two config files.
monkeypatch.setattr(
pip.configuration,
pip._internal.configuration,
'running_under_virtualenv',
lambda: True,
)
monkeypatch.setattr(os.path, 'exists', lambda filename: True)
cp = pip.configuration.Configuration(isolated=False)
cp = pip._internal.configuration.Configuration(isolated=False)

files = []
for _, val in cp._iter_config_files():
Expand Down
65 changes: 38 additions & 27 deletions tests/unit/test_pep425tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from mock import patch

from pip import pep425tags
from pip._internal import pep425tags


class TestPEP425Tags(object):
Expand All @@ -11,9 +11,9 @@ def mock_get_config_var(self, **kwd):
"""
Patch sysconfig.get_config_var for arbitrary keys.
"""
import pip.pep425tags
import pip._internal.pep425tags

get_config_var = pip.pep425tags.sysconfig.get_config_var
get_config_var = pip._internal.pep425tags.sysconfig.get_config_var

def _mock_get_config_var(var):
if var in kwd:
Expand All @@ -25,22 +25,25 @@ def abi_tag_unicode(self, flags, config_vars):
"""
Used to test ABI tags, verify correct use of the `u` flag
"""
import pip.pep425tags
import pip._internal.pep425tags

config_vars.update({'SOABI': None})
base = pip.pep425tags.get_abbr_impl() + pip.pep425tags.get_impl_ver()
base = pip._internal.pep425tags.get_abbr_impl() + \
pip._internal.pep425tags.get_impl_ver()

if sys.version_info < (3, 3):
config_vars.update({'Py_UNICODE_SIZE': 2})
mock_gcf = self.mock_get_config_var(**config_vars)
with patch('pip.pep425tags.sysconfig.get_config_var', mock_gcf):
abi_tag = pip.pep425tags.get_abi_tag()
with patch('pip._internal.pep425tags.sysconfig.get_config_var',
mock_gcf):
abi_tag = pip._internal.pep425tags.get_abi_tag()
assert abi_tag == base + flags

config_vars.update({'Py_UNICODE_SIZE': 4})
mock_gcf = self.mock_get_config_var(**config_vars)
with patch('pip.pep425tags.sysconfig.get_config_var', mock_gcf):
abi_tag = pip.pep425tags.get_abi_tag()
with patch('pip._internal.pep425tags.sysconfig.get_config_var',
mock_gcf):
abi_tag = pip._internal.pep425tags.get_abi_tag()
assert abi_tag == base + flags + 'u'

else:
Expand All @@ -49,8 +52,9 @@ def abi_tag_unicode(self, flags, config_vars):
# the 'u' so manual SOABI detection should not do so either.
config_vars.update({'Py_UNICODE_SIZE': None})
mock_gcf = self.mock_get_config_var(**config_vars)
with patch('pip.pep425tags.sysconfig.get_config_var', mock_gcf):
abi_tag = pip.pep425tags.get_abi_tag()
with patch('pip._internal.pep425tags.sysconfig.get_config_var',
mock_gcf):
abi_tag = pip._internal.pep425tags.get_abi_tag()
assert abi_tag == base + flags

def test_broken_sysconfig(self):
Expand All @@ -59,24 +63,26 @@ def test_broken_sysconfig(self):
Can be a problem on Python 2.7
Issue #1074.
"""
import pip.pep425tags
import pip._internal.pep425tags

def raises_ioerror(var):
raise IOError("I have the wrong path!")

with patch('pip.pep425tags.sysconfig.get_config_var', raises_ioerror):
assert len(pip.pep425tags.get_supported())
with patch('pip._internal.pep425tags.sysconfig.get_config_var',
raises_ioerror):
assert len(pip._internal.pep425tags.get_supported())

def test_no_hyphen_tag(self):
"""
Test that no tag contains a hyphen.
"""
import pip.pep425tags
import pip._internal.pep425tags

mock_gcf = self.mock_get_config_var(SOABI='cpython-35m-darwin')

with patch('pip.pep425tags.sysconfig.get_config_var', mock_gcf):
supported = pip.pep425tags.get_supported()
with patch('pip._internal.pep425tags.sysconfig.get_config_var',
mock_gcf):
supported = pip._internal.pep425tags.get_supported()

for (py, abi, plat) in supported:
assert '-' not in py
Expand Down Expand Up @@ -110,40 +116,45 @@ def test_manual_abi_dm_flags(self):

class TestManylinux1Tags(object):

@patch('pip.pep425tags.get_platform', lambda: 'linux_x86_64')
@patch('pip.utils.glibc.have_compatible_glibc', lambda major, minor: True)
@patch('pip._internal.pep425tags.get_platform', lambda: 'linux_x86_64')
@patch('pip._internal.utils.glibc.have_compatible_glibc',
lambda major, minor: True)
def test_manylinux1_compatible_on_linux_x86_64(self):
"""
Test that manylinux1 is enabled on linux_x86_64
"""
assert pep425tags.is_manylinux1_compatible()

@patch('pip.pep425tags.get_platform', lambda: 'linux_i686')
@patch('pip.utils.glibc.have_compatible_glibc', lambda major, minor: True)
@patch('pip._internal.pep425tags.get_platform', lambda: 'linux_i686')
@patch('pip._internal.utils.glibc.have_compatible_glibc',
lambda major, minor: True)
def test_manylinux1_compatible_on_linux_i686(self):
"""
Test that manylinux1 is enabled on linux_i686
"""
assert pep425tags.is_manylinux1_compatible()

@patch('pip.pep425tags.get_platform', lambda: 'linux_x86_64')
@patch('pip.utils.glibc.have_compatible_glibc', lambda major, minor: False)
@patch('pip._internal.pep425tags.get_platform', lambda: 'linux_x86_64')
@patch('pip._internal.utils.glibc.have_compatible_glibc',
lambda major, minor: False)
def test_manylinux1_2(self):
"""
Test that manylinux1 is disabled with incompatible glibc
"""
assert not pep425tags.is_manylinux1_compatible()

@patch('pip.pep425tags.get_platform', lambda: 'arm6vl')
@patch('pip.utils.glibc.have_compatible_glibc', lambda major, minor: True)
@patch('pip._internal.pep425tags.get_platform', lambda: 'arm6vl')
@patch('pip._internal.utils.glibc.have_compatible_glibc',
lambda major, minor: True)
def test_manylinux1_3(self):
"""
Test that manylinux1 is disabled on arm6vl
"""
assert not pep425tags.is_manylinux1_compatible()

@patch('pip.pep425tags.get_platform', lambda: 'linux_x86_64')
@patch('pip.utils.glibc.have_compatible_glibc', lambda major, minor: True)
@patch('pip._internal.pep425tags.get_platform', lambda: 'linux_x86_64')
@patch('pip._internal.utils.glibc.have_compatible_glibc',
lambda major, minor: True)
@patch('sys.platform', 'linux2')
def test_manylinux1_tag_is_first(self):
"""
Expand Down
15 changes: 0 additions & 15 deletions tests/unit/test_proxy.py

This file was deleted.

34 changes: 17 additions & 17 deletions tests/unit/test_req.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
from pip._vendor.packaging.markers import Marker
from pip._vendor.packaging.requirements import Requirement

from pip.commands.install import InstallCommand
from pip.download import PipSession, path_to_url
from pip.exceptions import (
from pip._internal.commands.install import InstallCommand
from pip._internal.download import PipSession, path_to_url
from pip._internal.exceptions import (
HashErrors, InstallationError, InvalidWheelFilename, PreviousBuildDirError
)
from pip.index import PackageFinder
from pip.operations.prepare import RequirementPreparer
from pip.req import InstallRequirement, RequirementSet
from pip.req.req_file import process_line
from pip.req.req_install import parse_editable
from pip.resolve import Resolver
from pip.utils import read_text_file
from pip._internal.index import PackageFinder
from pip._internal.operations.prepare import RequirementPreparer
from pip._internal.req import InstallRequirement, RequirementSet
from pip._internal.req.req_file import process_line
from pip._internal.req.req_install import parse_editable
from pip._internal.resolve import Resolver
from pip._internal.utils.misc import read_text_file
from tests.lib import assert_raises_regexp, requirements_file


Expand Down Expand Up @@ -306,7 +306,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.utils.open', om, create=True):
with patch('pip._internal.utils.misc.open', om, create=True):
with patch('locale.getpreferredencoding', em):
ret = read_text_file('foo')
assert ret == expected.decode('utf-8')
Expand Down Expand Up @@ -547,9 +547,9 @@ def test_requirement_file(self):
assert "If that is the case, use the '-r' flag to install" in err_msg


@patch('pip.req.req_install.os.path.abspath')
@patch('pip.req.req_install.os.path.exists')
@patch('pip.req.req_install.os.path.isdir')
@patch('pip._internal.req.req_install.os.path.abspath')
@patch('pip._internal.req.req_install.os.path.exists')
@patch('pip._internal.req.req_install.os.path.isdir')
def test_parse_editable_local(
isdir_mock, exists_mock, abspath_mock):
exists_mock.return_value = isdir_mock.return_value = True
Expand Down Expand Up @@ -578,9 +578,9 @@ def test_parse_editable_vcs_extras():
)


@patch('pip.req.req_install.os.path.abspath')
@patch('pip.req.req_install.os.path.exists')
@patch('pip.req.req_install.os.path.isdir')
@patch('pip._internal.req.req_install.os.path.abspath')
@patch('pip._internal.req.req_install.os.path.exists')
@patch('pip._internal.req.req_install.os.path.isdir')
def test_parse_editable_local_extras(
isdir_mock, exists_mock, abspath_mock):
exists_mock.return_value = isdir_mock.return_value = True
Expand Down
39 changes: 23 additions & 16 deletions tests/unit/test_req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
from mock import Mock, patch
from pretend import stub

import pip
from pip.download import PipSession
from pip.exceptions import InstallationError, RequirementsFileParseError
from pip.index import PackageFinder
from pip.req.req_file import (
import pip._internal.index
from pip._internal.download import PipSession
from pip._internal.exceptions import (
InstallationError, RequirementsFileParseError
)
from pip._internal.index import PackageFinder
from pip._internal.req.req_file import (
break_args_options, ignore_comments, join_lines, parse_requirements,
preprocess, process_line, skip_regex
)
from pip.req.req_install import InstallRequirement
from pip._internal.req.req_install import InstallRequirement
from tests.lib import requirements_file


Expand All @@ -33,7 +35,7 @@ def options(session):
return stub(
isolated_mode=False, index_url='default_url',
skip_requirements_regex=False,
format_control=pip.index.FormatControl(set(), set()))
format_control=pip._internal.index.FormatControl(set(), set()))


class TestPreprocess(object):
Expand Down Expand Up @@ -233,26 +235,26 @@ def test_yield_editable_constraint(self):
def test_nested_requirements_file(self, monkeypatch):
line = '-r another_file'
req = InstallRequirement.from_line('SomeProject')
import pip.req.req_file
import pip._internal.req.req_file

def stub_parse_requirements(req_url, finder, comes_from, options,
session, wheel_cache, constraint):
return [(req, constraint)]
parse_requirements_stub = stub(call=stub_parse_requirements)
monkeypatch.setattr(pip.req.req_file, 'parse_requirements',
monkeypatch.setattr(pip._internal.req.req_file, 'parse_requirements',
parse_requirements_stub.call)
assert list(process_line(line, 'filename', 1)) == [(req, False)]

def test_nested_constraints_file(self, monkeypatch):
line = '-c another_file'
req = InstallRequirement.from_line('SomeProject')
import pip.req.req_file
import pip._internal.req.req_file

def stub_parse_requirements(req_url, finder, comes_from, options,
session, wheel_cache, constraint):
return [(req, constraint)]
parse_requirements_stub = stub(call=stub_parse_requirements)
monkeypatch.setattr(pip.req.req_file, 'parse_requirements',
monkeypatch.setattr(pip._internal.req.req_file, 'parse_requirements',
parse_requirements_stub.call)
assert list(process_line(line, 'filename', 1)) == [(req, True)]

Expand Down Expand Up @@ -353,7 +355,8 @@ def parse(*args, **kwargs):
return iter([])
mock_parse = Mock()
mock_parse.side_effect = parse
monkeypatch.setattr(pip.req.req_file, 'parse_requirements', mock_parse)
monkeypatch.setattr(pip._internal.req.req_file, 'parse_requirements',
mock_parse)
list(process_line("-r reqs.txt", req_file, 1, finder=finder))
call = mock_parse.mock_calls[0]
assert call[1][0] == 'http://me.com/me/reqs.txt'
Expand All @@ -368,7 +371,8 @@ def parse(*args, **kwargs):
return iter([])
mock_parse = Mock()
mock_parse.side_effect = parse
monkeypatch.setattr(pip.req.req_file, 'parse_requirements', mock_parse)
monkeypatch.setattr(pip._internal.req.req_file, 'parse_requirements',
mock_parse)
list(process_line("-r reqs.txt", req_file, 1, finder=finder))
call = mock_parse.mock_calls[0]
assert call[1][0] == os.path.normpath('/path/reqs.txt')
Expand All @@ -383,7 +387,8 @@ def parse(*args, **kwargs):
return iter([])
mock_parse = Mock()
mock_parse.side_effect = parse
monkeypatch.setattr(pip.req.req_file, 'parse_requirements', mock_parse)
monkeypatch.setattr(pip._internal.req.req_file, 'parse_requirements',
mock_parse)
list(process_line("-r /other/reqs.txt", req_file, 1, finder=finder))
call = mock_parse.mock_calls[0]
assert call[1][0] == '/other/reqs.txt'
Expand All @@ -398,7 +403,8 @@ def parse(*args, **kwargs):
return iter([])
mock_parse = Mock()
mock_parse.side_effect = parse
monkeypatch.setattr(pip.req.req_file, 'parse_requirements', mock_parse)
monkeypatch.setattr(pip._internal.req.req_file, 'parse_requirements',
mock_parse)
list(process_line("-r http://me.com/me/reqs.txt", req_file, 1,
finder=finder))
call = mock_parse.mock_calls[0]
Expand Down Expand Up @@ -502,7 +508,8 @@ def test_req_file_parse_no_only_binary(self, data, finder):
list(parse_requirements(
data.reqfiles.join("supported_options2.txt"), finder,
session=PipSession()))
expected = pip.index.FormatControl(set(['fred']), set(['wilma']))
expected = pip._internal.index.FormatControl(
set(['fred']), set(['wilma']))
assert finder.format_control == expected

def test_req_file_parse_comment_start_of_line(self, tmpdir, finder):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest

from pip.req.req_install import InstallRequirement
from pip._internal.req.req_install import InstallRequirement


class TestInstallRequirementBuildDirectory(object):
Expand Down
16 changes: 10 additions & 6 deletions tests/unit/test_req_uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import pytest
from mock import Mock

import pip.req.req_uninstall
from pip.req.req_uninstall import (
import pip._internal.req.req_uninstall
from pip._internal.req.req_uninstall import (
UninstallPathSet, compact, compress_for_output_listing,
uninstallation_paths
)
Expand Down Expand Up @@ -95,7 +95,8 @@ def in_tmpdir(paths):

class TestUninstallPathSet(object):
def test_add(self, tmpdir, monkeypatch):
monkeypatch.setattr(pip.req.req_uninstall, 'is_local', mock_is_local)
monkeypatch.setattr(pip._internal.req.req_uninstall, 'is_local',
mock_is_local)
# Fix case for windows tests
file_extant = os.path.normcase(os.path.join(tmpdir, 'foo'))
file_nonexistent = os.path.normcase(
Expand All @@ -113,7 +114,8 @@ def test_add(self, tmpdir, monkeypatch):

@pytest.mark.skipif("sys.platform == 'win32'")
def test_add_symlink(self, tmpdir, monkeypatch):
monkeypatch.setattr(pip.req.req_uninstall, 'is_local', mock_is_local)
monkeypatch.setattr(pip._internal.req.req_uninstall, 'is_local',
mock_is_local)
f = os.path.join(tmpdir, 'foo')
with open(f, 'w'):
pass
Expand All @@ -125,7 +127,8 @@ def test_add_symlink(self, tmpdir, monkeypatch):
assert ups.paths == set([l])

def test_compact_shorter_path(self, monkeypatch):
monkeypatch.setattr(pip.req.req_uninstall, 'is_local', lambda p: True)
monkeypatch.setattr(pip._internal.req.req_uninstall, 'is_local',
lambda p: True)
monkeypatch.setattr('os.path.exists', lambda p: True)
# This deals with nt/posix path differences
short_path = os.path.normcase(os.path.abspath(
Expand All @@ -137,7 +140,8 @@ def test_compact_shorter_path(self, monkeypatch):

@pytest.mark.skipif("sys.platform == 'win32'")
def test_detect_symlink_dirs(self, monkeypatch, tmpdir):
monkeypatch.setattr(pip.req.req_uninstall, 'is_local', lambda p: True)
monkeypatch.setattr(pip._internal.req.req_uninstall, 'is_local',
lambda p: True)

# construct 2 paths:
# tmpdir/dir/file
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_unit_outdated.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import pytest
from pip._vendor import lockfile

from pip.index import InstallationCandidate
from pip.utils import outdated
from pip._internal.index import InstallationCandidate
from pip._internal.utils import outdated


class MockPackageFinder(object):
Expand Down
32 changes: 16 additions & 16 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
from mock import Mock, patch
from pip._vendor.six import BytesIO

from pip.exceptions import (
from pip._internal.exceptions import (
HashMismatch, HashMissing, InstallationError, UnsupportedPythonVersion
)
from pip.utils import (
from pip._internal.utils.encoding import auto_decode
from pip._internal.utils.glibc import check_glibc_version
from pip._internal.utils.hashes import Hashes, MissingHashes
from pip._internal.utils.misc import (
egg_link_path, ensure_dir, get_installed_distributions, normalize_path,
rmtree, untar_file, unzip_file
)
from pip.utils.encoding import auto_decode
from pip.utils.glibc import check_glibc_version
from pip.utils.hashes import Hashes, MissingHashes
from pip.utils.packaging import check_dist_requires_python
from pip.utils.temp_dir import TempDirectory
from pip._internal.utils.packaging import check_dist_requires_python
from pip._internal.utils.temp_dir import TempDirectory


class Tests_EgglinkPath:
Expand All @@ -50,7 +50,7 @@ def setup(self):
)

# patches
from pip import utils
from pip._internal.utils import misc as utils
self.old_site_packages = utils.site_packages
self.mock_site_packages = utils.site_packages = 'SITE_PACKAGES'
self.old_running_under_virtualenv = utils.running_under_virtualenv
Expand All @@ -65,7 +65,7 @@ def setup(self):
self.mock_isfile = path.isfile = Mock()

def teardown(self):
from pip import utils
from pip._internal.utils import misc as utils
utils.site_packages = self.old_site_packages
utils.running_under_virtualenv = self.old_running_under_virtualenv
utils.virtualenv_no_global = self.old_virtualenv_no_global
Expand Down Expand Up @@ -164,9 +164,9 @@ def test_noegglink_in_sitepkgs_venv_global(self):
assert egg_link_path(self.mock_dist) is None


@patch('pip.utils.dist_in_usersite')
@patch('pip.utils.dist_is_local')
@patch('pip.utils.dist_is_editable')
@patch('pip._internal.utils.misc.dist_in_usersite')
@patch('pip._internal.utils.misc.dist_is_local')
@patch('pip._internal.utils.misc.dist_is_editable')
class Tests_get_installed_distributions:
"""test util.get_installed_distributions"""

Expand Down Expand Up @@ -351,15 +351,15 @@ def call(self, *args, **kw):

def test_rmtree_retries(tmpdir, monkeypatch):
"""
Test pip.utils.rmtree will retry failures
Test pip._internal.utils.rmtree will retry failures
"""
monkeypatch.setattr(shutil, 'rmtree', Failer(duration=1).call)
rmtree('foo')


def test_rmtree_retries_for_3sec(tmpdir, monkeypatch):
"""
Test pip.utils.rmtree will retry failures for no more than 3 sec
Test pip._internal.utils.rmtree will retry failures for no more than 3 sec
"""
monkeypatch.setattr(shutil, 'rmtree', Failer(duration=5).call)
with pytest.raises(OSError):
Expand Down Expand Up @@ -404,7 +404,7 @@ def test_resolve_symlinks(self, tmpdir):


class TestHashes(object):
"""Tests for pip.utils.hashes"""
"""Tests for pip._internal.utils.hashes"""

def test_success(self, tmpdir):
"""Make sure no error is raised when at least one hash matches.
Expand Down Expand Up @@ -448,7 +448,7 @@ def test_non_zero(self):


class TestEncoding(object):
"""Tests for pip.utils.encoding"""
"""Tests for pip._internal.utils.encoding"""

def test_auto_decode_utf16_le(self):
data = (
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from mock import Mock
from pip._vendor.packaging.version import parse as parse_version

from pip.vcs import VersionControl
from pip.vcs.bazaar import Bazaar
from pip.vcs.git import Git
from pip.vcs.subversion import Subversion
from pip._internal.vcs import VersionControl
from pip._internal.vcs.bazaar import Bazaar
from pip._internal.vcs.git import Git
from pip._internal.vcs.subversion import Subversion
from tests.lib import pyversion

if pyversion >= '3':
Expand Down
46 changes: 25 additions & 21 deletions tests/unit/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
from mock import Mock, patch
from pip._vendor.packaging.requirements import Requirement

from pip import pep425tags, wheel
from pip.compat import WINDOWS
from pip.exceptions import InvalidWheelFilename, UnsupportedWheel
from pip.utils import unpack_file
from pip._internal import pep425tags, wheel
from pip._internal.compat import WINDOWS
from pip._internal.exceptions import InvalidWheelFilename, UnsupportedWheel
from pip._internal.utils.misc import unpack_file

from tests.lib import DATA_DIR


@pytest.mark.parametrize("console_scripts",
["pip = pip.main:pip", "pip:pip = pip.main:pip"])
["pip = pip._internal.main:pip",
"pip:pip = pip._internal.main:pip"])
def test_get_entrypoints(tmpdir, console_scripts):
entry_points = tmpdir.join("entry_points.txt")
with open(str(entry_points), "w") as fp:
Expand Down Expand Up @@ -136,8 +137,9 @@ def test_not_supported_version(self):
assert not w.supported(tags=[('py1', 'none', 'any')])

@patch('sys.platform', 'darwin')
@patch('pip.pep425tags.get_abbr_impl', lambda: 'cp')
@patch('pip.pep425tags.get_platform', lambda: 'macosx_10_9_intel')
@patch('pip._internal.pep425tags.get_abbr_impl', lambda: 'cp')
@patch('pip._internal.pep425tags.get_platform',
lambda: 'macosx_10_9_intel')
def test_supported_osx_version(self):
"""
Wheels built for macOS 10.6 are supported on 10.9
Expand All @@ -149,8 +151,9 @@ def test_supported_osx_version(self):
assert w.supported(tags=tags)

@patch('sys.platform', 'darwin')
@patch('pip.pep425tags.get_abbr_impl', lambda: 'cp')
@patch('pip.pep425tags.get_platform', lambda: 'macosx_10_6_intel')
@patch('pip._internal.pep425tags.get_abbr_impl', lambda: 'cp')
@patch('pip._internal.pep425tags.get_platform',
lambda: 'macosx_10_6_intel')
def test_not_supported_osx_version(self):
"""
Wheels built for macOS 10.9 are not supported on 10.6
Expand All @@ -160,27 +163,27 @@ def test_not_supported_osx_version(self):
assert not w.supported(tags=tags)

@patch('sys.platform', 'darwin')
@patch('pip.pep425tags.get_abbr_impl', lambda: 'cp')
@patch('pip._internal.pep425tags.get_abbr_impl', lambda: 'cp')
def test_supported_multiarch_darwin(self):
"""
Multi-arch wheels (intel) are supported on components (i386, x86_64)
"""
with patch('pip.pep425tags.get_platform',
with patch('pip._internal.pep425tags.get_platform',
lambda: 'macosx_10_5_universal'):
universal = pep425tags.get_supported(['27'], False)
with patch('pip.pep425tags.get_platform',
with patch('pip._internal.pep425tags.get_platform',
lambda: 'macosx_10_5_intel'):
intel = pep425tags.get_supported(['27'], False)
with patch('pip.pep425tags.get_platform',
with patch('pip._internal.pep425tags.get_platform',
lambda: 'macosx_10_5_x86_64'):
x64 = pep425tags.get_supported(['27'], False)
with patch('pip.pep425tags.get_platform',
with patch('pip._internal.pep425tags.get_platform',
lambda: 'macosx_10_5_i386'):
i386 = pep425tags.get_supported(['27'], False)
with patch('pip.pep425tags.get_platform',
with patch('pip._internal.pep425tags.get_platform',
lambda: 'macosx_10_5_ppc'):
ppc = pep425tags.get_supported(['27'], False)
with patch('pip.pep425tags.get_platform',
with patch('pip._internal.pep425tags.get_platform',
lambda: 'macosx_10_5_ppc64'):
ppc64 = pep425tags.get_supported(['27'], False)

Expand All @@ -200,15 +203,15 @@ def test_supported_multiarch_darwin(self):
assert w.supported(tags=ppc64)

@patch('sys.platform', 'darwin')
@patch('pip.pep425tags.get_abbr_impl', lambda: 'cp')
@patch('pip._internal.pep425tags.get_abbr_impl', lambda: 'cp')
def test_not_supported_multiarch_darwin(self):
"""
Single-arch wheels (x86_64) are not supported on multi-arch (intel)
"""
with patch('pip.pep425tags.get_platform',
with patch('pip._internal.pep425tags.get_platform',
lambda: 'macosx_10_5_universal'):
universal = pep425tags.get_supported(['27'], False)
with patch('pip.pep425tags.get_platform',
with patch('pip._internal.pep425tags.get_platform',
lambda: 'macosx_10_5_intel'):
intel = pep425tags.get_supported(['27'], False)

Expand Down Expand Up @@ -241,7 +244,7 @@ def test_support_index_min_none(self):
assert w.support_index_min(tags=[]) is None

def test_unpack_wheel_no_flatten(self):
from pip import utils
from pip._internal.utils import misc as utils
from tempfile import mkdtemp
from shutil import rmtree

Expand Down Expand Up @@ -359,7 +362,8 @@ def test_dist_info_contains_empty_dir(self, data, tmpdir):
class TestWheelBuilder(object):

def test_skip_building_wheels(self, caplog):
with patch('pip.wheel.WheelBuilder._build_one') as mock_build_one:
with patch('pip._internal.wheel.WheelBuilder._build_one') \
as mock_build_one:
wheel_req = Mock(is_wheel=True, editable=False, constraint=False)
reqset = Mock(requirements=Mock(values=lambda: [wheel_req]),
wheel_download_dir='/wheel/dir')
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ deps =
isort==4.2.5
commands =
flake8 .
isort --recursive --check-only --diff pip tests
isort --recursive --check-only --diff src/pip tests

[testenv:lint-py2]
basepython = python2
Expand Down