MCPcopy
hub / github.com/pex-tool/pex / test_download2

Function test_download2

tests/test_resolver.py:545–594  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

543
544
545def test_download2():
546 # type: () -> None
547 project1_sdist = create_sdist(
548 name="project1", version="1.0.0", extras_require={"foo": ["project2"]}
549 )
550 project2_wheel = build_wheel(
551 name="project2",
552 version="2.0.0",
553 # This is the last version of setuptools compatible with Python 2.7.
554 install_reqs=["setuptools==44.1.0"],
555 )
556
557 downloaded_by_target = defaultdict(list) # type: DefaultDict[Target, List[Distribution]]
558 result = download(
559 requirements=[parse_requirement_string("{}[foo]".format(project1_sdist))],
560 repos_configuration=ReposConfiguration.create(
561 indexes=[Repo(PYPI)], find_links=[Repo(os.path.dirname(project2_wheel))]
562 ),
563 resolver=ConfiguredResolver.default(),
564 )
565 for local_distribution in result.local_distributions:
566 distribution = Distribution.load(local_distribution.path)
567 downloaded_by_target[local_distribution.target].append(distribution)
568
569 assert 1 == len(downloaded_by_target)
570
571 target, distributions = downloaded_by_target.popitem()
572 assert targets.current() == target
573
574 distributions_by_name = {
575 distribution.project_name: distribution for distribution in distributions
576 }
577 assert 3 == len(distributions_by_name)
578
579 def assert_dist(
580 project_name, # type: str
581 version, # type: str
582 is_wheel, # type: bool
583 ):
584 # type: (...) -> None
585
586 dist = distributions_by_name[project_name]
587 assert version == dist.version
588 assert is_wheel == (
589 dist_metadata.is_wheel(dist.location) and zipfile.is_zipfile(dist.location)
590 )
591
592 assert_dist("project1", "1.0.0", is_wheel=False)
593 assert_dist("project2", "2.0.0", is_wheel=True)
594 assert_dist("setuptools", "44.1.0", is_wheel=True)
595
596
597@pytest.mark.skipif(

Callers

nothing calls this directly

Calls 11

downloadFunction · 0.90
parse_requirement_stringFunction · 0.90
RepoClass · 0.90
create_sdistFunction · 0.85
assert_distFunction · 0.85
appendMethod · 0.80
build_wheelFunction · 0.70
createMethod · 0.45
defaultMethod · 0.45
loadMethod · 0.45
currentMethod · 0.45

Tested by

no test coverage detected