test_python_requirement_solution.py (poetry-1.1.15) | : | test_python_requirement_solution.py (poetry-1.2.0) | ||
---|---|---|---|---|
import pytest | from __future__ import annotations | |||
from clikit.io.buffered_io import BufferedIO | ||||
from cleo.io.buffered_io import BufferedIO | ||||
from poetry.core.packages.dependency import Dependency | from poetry.core.packages.dependency import Dependency | |||
from poetry.mixology.failure import SolveFailure | from poetry.mixology.failure import SolveFailure | |||
from poetry.mixology.incompatibility import Incompatibility | from poetry.mixology.incompatibility import Incompatibility | |||
from poetry.mixology.incompatibility_cause import PythonCause | from poetry.mixology.incompatibility_cause import PythonCause | |||
from poetry.mixology.term import Term | from poetry.mixology.term import Term | |||
from poetry.puzzle.exceptions import SolverProblemError | from poetry.puzzle.exceptions import SolverProblemError | |||
from poetry.utils._compat import PY36 | ||||
@pytest.mark.skipif( | ||||
not PY36, reason="Error solutions are only available for Python ^3.6" | ||||
) | ||||
def test_it_provides_the_correct_solution(): | def test_it_provides_the_correct_solution(): | |||
from poetry.mixology.solutions.solutions import PythonRequirementSolution | from poetry.mixology.solutions.solutions import PythonRequirementSolution | |||
incompatibility = Incompatibility( | incompatibility = Incompatibility( | |||
[Term(Dependency("foo", "^1.0"), True)], PythonCause("^3.5", ">=3.6") | [Term(Dependency("foo", "^1.0"), True)], PythonCause("^3.5", ">=3.6") | |||
) | ) | |||
exception = SolverProblemError(SolveFailure(incompatibility)) | exception = SolverProblemError(SolveFailure(incompatibility)) | |||
solution = PythonRequirementSolution(exception) | solution = PythonRequirementSolution(exception) | |||
title = "Check your dependencies Python requirement." | title = "Check your dependencies Python requirement." | |||
description = """\ | description = """\ | |||
The Python requirement can be specified via the `python` or `markers` properties | The Python requirement can be specified via the `python` or `markers` properties | |||
For foo, a possible solution would be to set the `python` property to ">=3.6,<4. 0"\ | For foo, a possible solution would be to set the `python` property to ">=3.6,<4. 0"\ | |||
""" | """ | |||
links = [ | links = [ | |||
"https://python-poetry.org/docs/dependency-specification/#python-restric | "https://python-poetry.org/docs/dependency-specification/#python-restric | |||
ted-dependencies", | ted-dependencies", # noqa: E501 | |||
"https://python-poetry.org/docs/dependency-specification/#using-environm | "https://python-poetry.org/docs/dependency-specification/#using-environm | |||
ent-markers", | ent-markers", # noqa: E501 | |||
] | ] | |||
assert title == solution.solution_title | assert title == solution.solution_title | |||
assert ( | assert ( | |||
description == BufferedIO().remove_format(solution.solution_description) .strip() | description == BufferedIO().remove_format(solution.solution_description) .strip() | |||
) | ) | |||
assert links == solution.documentation_links | assert links == solution.documentation_links | |||
End of changes. 6 change blocks. | ||||
11 lines changed or deleted | 7 lines changed or added |