def test_should_cache_git_sha(tmpdir: Path) -> None: repo_path = os.fspath(_create_test_package(tmpdir, name="mypkg")) commit = Git.get_revision(repo_path) # a link referencing a sha should be cached url = "git+https://g.c/o/r@" + commit + "#egg=mypkg" req = ReqMock(link=Link(url), source_dir=repo_path) assert wheel_builder._should_cache(cast(InstallRequirement, req)) # a link not referencing a sha should not be cached url = "git+https://g.c/o/r@master#egg=mypkg" req = ReqMock(link=Link(url), source_dir=repo_path) assert not wheel_builder._should_cache(cast(InstallRequirement, req))
def test_should_cache_git_sha(script, tmpdir): repo_path = _create_test_package(script, name="mypkg") commit = script.run("git", "rev-parse", "HEAD", cwd=repo_path).stdout.strip() # a link referencing a sha should be cached url = "git+https://g.c/o/r@" + commit + "#egg=mypkg" req = ReqMock(link=Link(url), source_dir=repo_path) assert wheel_builder._should_cache(req) # a link not referencing a sha should not be cached url = "git+https://g.c/o/r@master#egg=mypkg" req = ReqMock(link=Link(url), source_dir=repo_path) assert not wheel_builder._should_cache(req)
def test_should_cache( req, disallow_binaries, expected ): def check_binary_allowed(req): return not disallow_binaries should_cache = wheel_builder._should_cache( req, check_binary_allowed ) if not wheel_builder.should_build_for_install_command( req, check_binary_allowed=check_binary_allowed ): # never cache if pip install would not have built) assert not should_cache assert should_cache is expected
def test_should_cache(req: ReqMock, expected: bool) -> None: assert wheel_builder._should_cache(cast(InstallRequirement, req)) is expected
def test_should_cache(req, expected): assert wheel_builder._should_cache(req) is expected