コード例 #1
0
ファイル: installer.py プロジェクト: timgates42/poetry
    def _populate_lockfile_repo(self, repo: LockfileRepository,
                                ops: Sequence[Operation]) -> None:
        for op in ops:
            if isinstance(op, Uninstall):
                continue
            elif isinstance(op, Update):
                package = op.target_package
            else:
                package = op.package

            if not repo.has_package(package):
                repo.add_package(package)
コード例 #2
0
def test_has_package():
    repo = LockfileRepository()

    url_package = Package("a",
                          "1.0",
                          source_type="url",
                          source_url="https://example.org/a.whl")
    assert not repo.has_package(url_package)
    repo.add_package(url_package)

    pypi_package = Package("a", "1.0")
    assert not repo.has_package(pypi_package)
    repo.add_package(pypi_package)

    url_package_2 = Package("a",
                            "1.0",
                            source_type="url",
                            source_url="https://example.org/a-1.whl")
    assert not repo.has_package(url_package_2)
    repo.add_package(url_package_2)

    assert len(repo.packages) == 3
    assert repo.has_package(deepcopy(url_package))
    assert repo.has_package(deepcopy(pypi_package))
    assert repo.has_package(deepcopy(url_package_2))
コード例 #3
0
def test_remove_package():
    url_package = Package("a",
                          "1.0",
                          source_type="url",
                          source_url="https://example.org/a.whl")
    pypi_package = Package("a", "1.0")
    url_package_2 = Package("a",
                            "1.0",
                            source_type="url",
                            source_url="https://example.org/a-1.whl")

    repo = LockfileRepository()
    repo.add_package(url_package)
    repo.add_package(pypi_package)
    repo.add_package(url_package_2)

    assert len(repo.packages) == 3

    repo.remove_package(deepcopy(pypi_package))
    assert len(repo.packages) == 2
    repo.remove_package(pypi_package)
    assert len(repo.packages) == 2

    repo.remove_package(deepcopy(url_package_2))
    assert len(repo.packages) == 1
    assert repo.packages[0] == url_package
    repo.remove_package(url_package_2)
    assert len(repo.packages) == 1