def test_toggle_reuse_hashes_local_repository(capfd, pip_conf, from_line, pypi_repository, reuse_hashes, expected): # Create an install requirement with the hashes included in its options options = { "hashes": { "sha256": [entry.split(":")[1] for entry in NONSENSE] } } req = from_line("small-fake-a==0.1", options=options) existing_pins = {name_from_req(req): req} local_repository = LocalRequirementsRepository(existing_pins, pypi_repository, reuse_hashes=reuse_hashes) with local_repository.allow_all_wheels(): assert local_repository.get_hashes( from_line("small-fake-a==0.1")) == expected captured = capfd.readouterr() assert captured.out == "" if reuse_hashes: assert captured.err == "" else: assert (captured.err.strip() == "Couldn't get hashes from PyPI, fallback to hashing files")
def test_no_upgrades(base_resolver, repository, from_line, input, pins, expected): input = [from_line(line) for line in input] existing_pins = dict() for line in pins: ireq = from_line(line) existing_pins[name_from_req(ireq.req)] = ireq local_repository = LocalRequirementsRepository(existing_pins, repository) output = base_resolver(input, prereleases=False, repository=local_repository).resolve() output = {str(line) for line in output} assert output == {str(line) for line in expected}
def test_get_hashes_local_repository_cache_hit(from_line, repository): # Create an install requirement with the hashes included in its options options = {"hashes": {"sha256": [entry.split(":")[1] for entry in EXPECTED]}} req = from_line("small-fake-a==0.1", options=options) existing_pins = {name_from_req(req): req} # Use fake repository so that we know the hashes are coming from cache local_repository = LocalRequirementsRepository(existing_pins, repository) with local_repository.allow_all_wheels(): hashes = local_repository.get_hashes(from_line("small-fake-a==0.1")) assert hashes == EXPECTED
def test_get_hashes_local_repository_cache_hit(from_line, repository): # Create an install requirement with the hashes included in its options options = {} options['hashes'] = {'sha256': [entry.split(':')[1] for entry in EXPECTED]} req = from_line('cffi==1.9.1', options=options) existing_pins = {name_from_req(req): req} # Use fake repository so that we know the hashes are coming from cache local_repository = LocalRequirementsRepository(existing_pins, repository) with repository.allow_all_wheels(): hashes = local_repository.get_hashes(from_line('cffi==1.9.1')) assert hashes == EXPECTED
def test_toggle_reuse_hashes_local_repository( pip_conf, from_line, pypi_repository, reuse_hashes, expected ): # Create an install requirement with the hashes included in its options options = {"hashes": {"sha256": [entry.split(":")[1] for entry in NONSENSE]}} req = from_line("small-fake-a==0.1", options=options) existing_pins = {name_from_req(req): req} local_repository = LocalRequirementsRepository( existing_pins, pypi_repository, reuse_hashes=reuse_hashes ) with local_repository.allow_all_wheels(): assert local_repository.get_hashes(from_line("small-fake-a==0.1")) == expected
def test_name_from_req_with_project_name(from_line): ireq = from_line("foo==1.8") ireq.req.project_name = "bar" assert name_from_req(ireq.req) == "bar"
def test_name_from_req(from_line): ireq = from_line("django==1.8") assert name_from_req(ireq.req) == "django"
def test_name_from_req_with_project_name(from_line): ireq = from_line('foo==1.8') ireq.req.project_name = 'bar' assert name_from_req(ireq.req) == 'bar'
def test_name_from_req(from_line): ireq = from_line('django==1.8') assert name_from_req(ireq.req) == 'django'