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

Fix tests for subdirectory install

- make assert_install test clearer
- Add option allowing for testing install from an editable subdirectory
This commit is contained in:
Matthew Iversen 2014-03-09 05:33:05 +11:00
parent d3acfe0858
commit 4008c0a111
2 changed files with 18 additions and 14 deletions

View file

@ -132,11 +132,11 @@ def test_respect_order_in_requirements_file(script, data):
def test_install_local_editable_with_subdirectory(script):
version_pkg_path = _create_test_package_with_subdirectory(script,
'version_subpkg')
'version_subdir')
result = script.pip(
'install', '-e',
'%s#egg=version_subpkg&subdirectory=version_subpkg' %
'%s#egg=version_subpkg&subdirectory=version_subdir' %
('git+file://%s' % version_pkg_path,)
)
result.assert_installed('version-subpkg')
result.assert_installed('version-subpkg', sub_dir='version_subdir')

View file

@ -130,11 +130,14 @@ class TestPipResult(object):
def assert_installed(self, pkg_name, editable=True, with_files=[],
without_files=[], without_egg_link=False,
use_user_site=False):
use_user_site=False, sub_dir=False):
e = self.test_env
if editable:
pkg_dir = e.venv / 'src' / pkg_name.lower()
# If package was installed in a sub directory
if sub_dir:
pkg_dir = pkg_dir / sub_dir
else:
without_egg_link = True
pkg_dir = e.site_packages / pkg_name
@ -159,18 +162,19 @@ class TestPipResult(object):
egg_link_file = self.files_created[egg_link_path]
if not ( # FIXME: I don't understand why there's a trailing . here
egg_link_file.bytes.endswith('.')
and egg_link_file.bytes[:-1].strip().endswith(pkg_dir)):
# FIXME: I don't understand why there's a trailing . here
if not (egg_link_file.bytes.endswith('\n.')
and egg_link_file.bytes[:-2].endswith(pkg_dir)):
raise TestFailure(textwrap.dedent(u('''\
Incorrect egg_link file %r
Expected ending: %r
------- Actual contents -------
%s
-------------------------------''' % (
Incorrect egg_link file %r
Expected ending: %r
------- Actual contents -------
%s
-------------------------------''' % (
egg_link_file,
pkg_dir + u('\n.'),
egg_link_file.bytes))))
pkg_dir + '\n.',
repr(egg_link_file.bytes))
)))
if use_user_site:
pth_file = e.user_site / 'easy-install.pth'