"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/mixology/helpers.py" between
poetry-1.1.15.tar.gz and poetry-1.2.0.tar.gz

About: Poetry is a tool for dependency management and packaging in Python.

helpers.py  (poetry-1.1.15):helpers.py  (poetry-1.2.0)
from poetry.core.packages import Package from __future__ import annotations
from typing import TYPE_CHECKING
from poetry.core.packages.package import Package
from poetry.factory import Factory from poetry.factory import Factory
from poetry.mixology.failure import SolveFailure from poetry.mixology.failure import SolveFailure
from poetry.mixology.version_solver import VersionSolver from poetry.mixology.version_solver import VersionSolver
from poetry.packages import DependencyPackage from poetry.packages import DependencyPackage
def add_to_repo(repository, name, version, deps=None, python=None): if TYPE_CHECKING:
package = Package(name, version) from poetry.core.packages.project_package import ProjectPackage
from poetry.mixology import SolverResult
from poetry.repositories import Repository
from tests.mixology.version_solver.conftest import Provider
def add_to_repo(
repository: Repository,
name: str,
version: str,
deps: dict[str, str] | None = None,
python: str | None = None,
yanked: bool = False,
) -> None:
package = Package(name, version, yanked=yanked)
if python: if python:
package.python_versions = python package.python_versions = python
if deps: if deps:
for dep_name, dep_constraint in deps.items(): for dep_name, dep_constraint in deps.items():
package.add_dependency(Factory.create_dependency(dep_name, dep_const raint)) package.add_dependency(Factory.create_dependency(dep_name, dep_const raint))
repository.add_package(package) repository.add_package(package)
def check_solver_result( def check_solver_result(
root, provider, result=None, error=None, tries=None, locked=None, use_latest root: ProjectPackage,
=None provider: Provider,
): result: dict[str, str] | None = None,
error: str | None = None,
tries: int | None = None,
locked: dict[str, Package] | None = None,
use_latest: list[str] | None = None,
) -> SolverResult | None:
if locked is not None: if locked is not None:
locked = {k: DependencyPackage(l.to_dependency(), l) for k, l in locked. locked = {
items()} k: [DependencyPackage(l.to_dependency(), l)] for k, l in locked.item
s()
}
solver = VersionSolver(root, provider, locked=locked, use_latest=use_latest) solver = VersionSolver(root, provider, locked=locked, use_latest=use_latest)
try: try:
solution = solver.solve() solution = solver.solve()
except SolveFailure as e: except SolveFailure as e:
if error: if error:
assert str(e) == error assert str(e) == error
if tries is not None: if tries is not None:
assert solver.solution.attempted_solutions == tries assert solver.solution.attempted_solutions == tries
return return None
raise raise
except AssertionError as e:
if error:
assert str(e) == error
return None
raise
packages = {} packages = {}
for package in solution.packages: for package in solution.packages:
packages[package.name] = str(package.version) packages[package.name] = str(package.version)
assert result == packages assert packages == result
if tries is not None: if tries is not None:
assert solution.attempted_solutions == tries assert solution.attempted_solutions == tries
return solution
 End of changes. 9 change blocks. 
11 lines changed or deleted 41 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)