mirror of https://github.com/pypa/pip
Add tests for constraints
This commit is contained in:
parent
43426eea34
commit
5186f05bd7
|
@ -529,3 +529,54 @@ def test_new_resolver_handles_prerelease(
|
|||
*pip_args
|
||||
)
|
||||
assert_installed(script, pkg=expected_version)
|
||||
|
||||
|
||||
def test_new_resolver_constraints(script):
|
||||
create_basic_wheel_for_package(script, "pkg", "1.0")
|
||||
create_basic_wheel_for_package(script, "pkg", "2.0")
|
||||
create_basic_wheel_for_package(script, "pkg", "3.0")
|
||||
constraints_file = script.scratch_path / "constraints.txt"
|
||||
constraints_file.write_text("pkg<2.0\nconstraint_only<1.0")
|
||||
script.pip(
|
||||
"install", "--unstable-feature=resolver",
|
||||
"--no-cache-dir", "--no-index",
|
||||
"--find-links", script.scratch_path,
|
||||
"-c", constraints_file,
|
||||
"pkg"
|
||||
)
|
||||
assert_installed(script, pkg="1.0")
|
||||
assert_not_installed(script, "constraint_only")
|
||||
|
||||
|
||||
def test_new_resolver_constraint_on_dependency(script):
|
||||
create_basic_wheel_for_package(script, "base", "1.0", depends=["dep"])
|
||||
create_basic_wheel_for_package(script, "dep", "1.0")
|
||||
constraints_file = script.scratch_path / "constraints.txt"
|
||||
constraints_file.write_text("dep==1.0")
|
||||
script.pip(
|
||||
"install", "--unstable-feature=resolver",
|
||||
"--no-cache-dir", "--no-index",
|
||||
"--find-links", script.scratch_path,
|
||||
"-c", constraints_file,
|
||||
"base"
|
||||
)
|
||||
assert_installed(script, base="1.0")
|
||||
assert_installed(script, dep="1.0")
|
||||
|
||||
|
||||
def test_new_resolver_constraint_on_path(script):
|
||||
setup_py = script.scratch_path / "setup.py"
|
||||
text = "from setuptools import setup\nsetup(name='foo', version='2.0')"
|
||||
setup_py.write_text(text)
|
||||
constraints_txt = script.scratch_path / "constraints.txt"
|
||||
constraints_txt.write_text("foo==1.0")
|
||||
result = script.pip(
|
||||
"install", "--unstable-feature=resolver",
|
||||
"--no-cache-dir", "--no-index",
|
||||
"-c", constraints_txt,
|
||||
str(script.scratch_path),
|
||||
expect_error=True,
|
||||
)
|
||||
|
||||
msg = "installation from path or url cannot be constrained to a version"
|
||||
assert msg in result.stderr, str(result)
|
||||
|
|
Loading…
Reference in New Issue