def test_download_wheel(package, pip_output, expected, monkeypatch): cache_dir = "~/Library/Caches/pip/wheels/pipgrip" def patch_os_walk(*args, **kwargs): yield cache_dir, None, [ "a.whl", "jupyterlab_black-0.2.1-py3-none-any.whl", "x.whl", ] def patch_getmtime(*args, **kwargs): return 0 def patch_pip_output(*args, **kwargs): return pip_output monkeypatch.setattr( pipgrip.pipper.os, "walk", patch_os_walk, ) monkeypatch.setattr( pipgrip.pipper.os.path, "getmtime", patch_getmtime, ) monkeypatch.setattr( pipgrip.pipper, "stream_bash_command", patch_pip_output, ) assert (_download_wheel( package, "https://pypi.org/simple", "https://pypi.org/simple", False, cache_dir, ) == os.path.join(cache_dir, expected.lstrip(os.path.sep)))
import pytest from click.testing import CliRunner import pipgrip.pipper from pipgrip import __version__ from pipgrip.cli import flatten, main from pipgrip.pipper import _download_wheel self_wheel = _download_wheel(".", None, None, None, "./tests/assets") # fmt: off def mock_download_wheel(package, *args, **kwargs): wheelhouse = { ".": self_wheel, "setuptools>=38.3": "./tests/assets/setuptools-44.0.0-py2.py3-none-any.whl", "pkginfo>=1.4.2": "./tests/assets/pkginfo-1.5.0.1-py2.py3-none-any.whl", "packaging>=17": "./tests/assets/packaging-20.0-py2.py3-none-any.whl", "click": "./tests/assets/Click-7.0-py2.py3-none-any.whl", "anytree": "./tests/assets/anytree-2.7.3-py2.py3-none-any.whl", "six": "./tests/assets/six-1.13.0-py2.py3-none-any.whl", "wheel": "./tests/assets/wheel-0.33.6-py2.py3-none-any.whl", "pyparsing>=2.0.2": "./tests/assets/pyparsing-2.4.6-py2.py3-none-any.whl", "requests==2.22.0": "./tests/assets/requests-2.22.0-py2.py3-none-any.whl", "urllib3<1.25.0|>1.25.0,<1.25.1|>1.25.1,<1.26,>=1.21.1": "./tests/assets/urllib3-1.25-py2.py3-none-any.whl", "urllib3==1.25.7":