mirror of https://github.com/pypa/pip
add freeze test with git subdirectory and srcdir
This commit is contained in:
parent
b8549e3629
commit
7d7b50a990
|
@ -4,7 +4,7 @@ import textwrap
|
|||
import pytest
|
||||
from doctest import OutputChecker, ELLIPSIS
|
||||
|
||||
from tests.lib import _create_test_package
|
||||
from tests.lib import _create_test_package, _create_test_package_with_srcdir
|
||||
|
||||
|
||||
distribute_re = re.compile('^distribute==[0-9.]+\n', re.MULTILINE)
|
||||
|
@ -154,6 +154,53 @@ def test_freeze_git_clone(script, tmpdir):
|
|||
_check_output(result, expected)
|
||||
|
||||
|
||||
@pytest.mark.git
|
||||
def test_freeze_git_clone_srcdir(script, tmpdir):
|
||||
"""
|
||||
Test freezing a Git clone where setup.py is in a subdirectory
|
||||
relative the repo root and the source code is in a subdirectory
|
||||
relative to setup.py.
|
||||
"""
|
||||
# Returns path to a generated package called "version_pkg"
|
||||
pkg_version = _create_test_package_with_srcdir(script)
|
||||
|
||||
result = script.run(
|
||||
'git', 'clone', pkg_version, 'pip-test-package',
|
||||
expect_stderr=True,
|
||||
)
|
||||
repo_dir = script.scratch_path / 'pip-test-package'
|
||||
result = script.run(
|
||||
'python', 'setup.py', 'develop',
|
||||
cwd=repo_dir / 'subdir',
|
||||
expect_stderr=True,
|
||||
)
|
||||
result = script.pip('freeze', expect_stderr=True)
|
||||
expected = textwrap.dedent(
|
||||
"""
|
||||
Script result: ...pip freeze
|
||||
-- stdout: --------------------
|
||||
...-e git+...#egg=version_pkg-master&subdirectory=subdir
|
||||
...
|
||||
"""
|
||||
).strip()
|
||||
_check_output(result, expected)
|
||||
|
||||
result = script.pip(
|
||||
'freeze', '-f', '%s#egg=pip_test_package' % repo_dir,
|
||||
expect_stderr=True,
|
||||
)
|
||||
expected = textwrap.dedent(
|
||||
"""
|
||||
Script result: pip freeze -f %(repo)s#egg=pip_test_package
|
||||
-- stdout: --------------------
|
||||
-f %(repo)s#egg=pip_test_package...
|
||||
-e git+...#egg=version_pkg-master&subdirectory=subdir
|
||||
...
|
||||
""" % {'repo': repo_dir},
|
||||
).strip()
|
||||
_check_output(result, expected)
|
||||
|
||||
|
||||
@pytest.mark.mercurial
|
||||
def test_freeze_mercurial_clone(script, tmpdir):
|
||||
"""
|
||||
|
|
|
@ -469,6 +469,28 @@ setup(name='version_subpkg',
|
|||
return version_pkg_path
|
||||
|
||||
|
||||
def _create_test_package_with_srcdir(script, name='version_pkg', vcs='git'):
|
||||
script.scratch_path.join(name).mkdir()
|
||||
version_pkg_path = script.scratch_path / name
|
||||
subdir_path = version_pkg_path.join('subdir')
|
||||
subdir_path.mkdir()
|
||||
src_path = subdir_path.join('src')
|
||||
src_path.mkdir()
|
||||
pkg_path = src_path.join('pkg')
|
||||
pkg_path.mkdir()
|
||||
pkg_path.join('__init__.py').write('')
|
||||
subdir_path.join("setup.py").write(textwrap.dedent("""
|
||||
from setuptools import setup, find_packages
|
||||
setup(
|
||||
name='{name}',
|
||||
version='0.1',
|
||||
packages=find_packages(),
|
||||
package_dir={{'': 'src'}},
|
||||
)
|
||||
""".format(name=name)))
|
||||
return _vcs_add(script, version_pkg_path, vcs)
|
||||
|
||||
|
||||
def _create_test_package(script, name='version_pkg', vcs='git'):
|
||||
script.scratch_path.join(name).mkdir()
|
||||
version_pkg_path = script.scratch_path / name
|
||||
|
|
Loading…
Reference in New Issue