Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc. changes to support upcoming changes to poetry-core #4604

Merged
merged 4 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ def search_for_vcs(self, dependency: VCSDependency) -> List[Package]:
dependency._constraint = package.version
dependency._pretty_constraint = package.version.text

dependency._source_reference = package.source_reference
dependency._source_resolved_reference = package.source_resolved_reference

if hasattr(package, "source_subdirectory") and hasattr(
dependency, "_source_subdirectory"
):
# this is supported only for poetry-core >= 1.1.0a7
dependency._source_subdirectory = package.source_subdirectory

self._deferred_cache[dependency] = package

return [package]
Expand Down
23 changes: 15 additions & 8 deletions tests/puzzle/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from poetry.core.packages.dependency import Dependency
from poetry.core.packages.package import Package
from poetry.core.packages.project_package import ProjectPackage
from poetry.core.packages.vcs_dependency import VCSDependency
from poetry.core.version.markers import parse_marker
from poetry.factory import Factory
from poetry.puzzle import Solver
Expand All @@ -24,6 +25,12 @@
from tests.repositories.test_pypi_repository import MockRepository as MockPyPIRepository


DEFAULT_SOURCE_REF = (
VCSDependency("poetry", "git", "git@github.com:python-poetry/poetry.git").branch
or "HEAD"
abn marked this conversation as resolved.
Show resolved Hide resolved
)


class Provider(BaseProvider):
def set_package_python_versions(self, python_versions):
self._package.python_versions = python_versions
Expand Down Expand Up @@ -1230,7 +1237,7 @@ def test_solver_can_resolve_git_dependencies(solver, repo, package):
"0.1.2",
source_type="git",
source_url="https://github.com/demo/demo.git",
source_reference="master",
source_reference=DEFAULT_SOURCE_REF,
source_resolved_reference="9cf87a285a2d3fbb0b9fa621997b3acc3631ed24",
)

Expand All @@ -1242,7 +1249,7 @@ def test_solver_can_resolve_git_dependencies(solver, repo, package):
op = ops[1]

assert op.package.source_type == "git"
assert op.package.source_reference == "master"
assert op.package.source_reference == DEFAULT_SOURCE_REF
assert op.package.source_resolved_reference.startswith("9cf87a2")


Expand All @@ -1265,7 +1272,7 @@ def test_solver_can_resolve_git_dependencies_with_extras(solver, repo, package):
"0.1.2",
source_type="git",
source_url="https://github.com/demo/demo.git",
source_reference="master",
source_reference=DEFAULT_SOURCE_REF,
source_resolved_reference="9cf87a285a2d3fbb0b9fa621997b3acc3631ed24",
)

Expand Down Expand Up @@ -1577,15 +1584,15 @@ def test_solver_git_dependencies_update(solver, repo, package, installed):
"0.1.2",
source_type="git",
source_url="https://github.com/demo/demo.git",
source_reference="master",
source_reference=DEFAULT_SOURCE_REF,
source_resolved_reference="123456",
)
demo = Package(
"demo",
"0.1.2",
source_type="git",
source_url="https://github.com/demo/demo.git",
source_reference="master",
source_reference=DEFAULT_SOURCE_REF,
source_resolved_reference="9cf87a285a2d3fbb0b9fa621997b3acc3631ed24",
)
installed.add_package(demo_installed)
Expand All @@ -1608,7 +1615,7 @@ def test_solver_git_dependencies_update(solver, repo, package, installed):

assert op.job_type == "update"
assert op.package.source_type == "git"
assert op.package.source_reference == "master"
assert op.package.source_reference == DEFAULT_SOURCE_REF
assert op.package.source_resolved_reference.startswith("9cf87a2")
assert op.initial_package.source_resolved_reference == "123456"

Expand Down Expand Up @@ -2359,8 +2366,8 @@ def test_solver_does_not_fail_with_locked_git_and_non_git_dependencies(
"0.1.2",
source_type="git",
source_url="https://github.com/demo/demo.git",
source_reference="master",
source_resolved_reference="commit",
source_reference=DEFAULT_SOURCE_REF,
source_resolved_reference="9cf87a285a2d3fbb0b9fa621997b3acc3631ed24",
)

installed.add_package(git_package)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from entrypoints import EntryPoint

from poetry.core.semver.helpers import parse_constraint
from poetry.core.toml.file import TOMLFile
from poetry.factory import Factory
from poetry.plugins.plugin import Plugin
Expand Down Expand Up @@ -70,7 +71,7 @@ def test_create_poetry():

pathlib2 = dependencies["pathlib2"]
assert pathlib2.pretty_constraint == "^2.2"
assert pathlib2.python_versions == "~2.7"
assert parse_constraint(pathlib2.python_versions) == parse_constraint("~2.7")
assert not pathlib2.is_optional()

demo = dependencies["demo"]
Expand Down