Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests adjustments #1

Merged
merged 1 commit into from
Feb 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions tests/test_repository_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,19 @@ def test_wheel_cache_cleanup_called(
WheelCache.return_value.cleanup.assert_called_once_with()


@mock.patch("piptools.repositories.pypi.PyPIRepository.resolve_reqs") # to run offline
@mock.patch("piptools.repositories.pypi.WheelCache")
def test_relative_path_cache_dir(WheelCache, resolve_reqs, from_line):
def test_relative_path_cache_dir_is_normalized(from_line):
relative_cache_dir = "pypi-repo-cache"
pypi_repository = PyPIRepository([], cache_dir=relative_cache_dir)

assert os.path.isabs(pypi_repository._cache_dir)
assert pypi_repository._cache_dir.endswith(relative_cache_dir)


def test_relative_path_pip_cache_dir_is_normalized(from_line, tmpdir):
relative_cache_dir = "pip-cache"
pypi_repository = PyPIRepository(
["--index-url", PyPIRepository.DEFAULT_INDEX_URL], cache_dir=relative_cache_dir
["--cache-dir", relative_cache_dir], cache_dir=str(tmpdir / "pypi-repo-cache")
)
ireq = from_line("six==1.10.0")
pypi_repository.get_dependencies(ireq)
WheelCache.assert_called_once()
cache_dir = WheelCache.call_args[0][0]
assert os.path.isabs(cache_dir)
assert cache_dir.endswith(relative_cache_dir)

assert os.path.isabs(pypi_repository.options.cache_dir)
assert pypi_repository.options.cache_dir.endswith(relative_cache_dir)