Fix tests when running in git linked worktree.

This commit is contained in:
Chris Hunt 2019-08-07 22:59:10 -04:00
parent e4c32b9917
commit 2571398f4d
2 changed files with 14 additions and 4 deletions

View File

@ -169,10 +169,16 @@ def isolate(tmpdir):
@pytest.fixture(scope='session')
def pip_src(tmpdir_factory):
def not_code_files_and_folders(path, names):
# In the root directory, ignore all folders except "src"
# In the root directory...
if path == SRC_DIR:
# ignore all folders except "src"
folders = {name for name in names if os.path.isdir(path / name)}
return folders - {"src"}
to_ignore = folders - {"src"}
# and ignore ".git" if present (which may be a file if in a linked
# worktree).
if ".git" in names:
to_ignore.add(".git")
return to_ignore
# Ignore all compiled files and egg-info.
ignored = list()

View File

@ -123,15 +123,19 @@ def test_should_add_vcs_url_prefix(vcs_cls, remote_url, expected):
assert actual == expected
@patch('pip._internal.vcs.git.Git.get_revision')
@patch('pip._internal.vcs.git.Git.get_remote_url')
@patch('pip._internal.vcs.git.Git.get_revision')
@patch('pip._internal.vcs.git.Git.get_subdirectory')
@pytest.mark.network
def test_git_get_src_requirements(mock_get_remote_url, mock_get_revision):
def test_git_get_src_requirements(
mock_get_subdirectory, mock_get_revision, mock_get_remote_url
):
git_url = 'https://github.com/pypa/pip-test-package'
sha = '5547fa909e83df8bd743d3978d6667497983a4b7'
mock_get_remote_url.return_value = git_url
mock_get_revision.return_value = sha
mock_get_subdirectory.return_value = None
ret = Git.get_src_requirement('.', 'pip-test-package')