Skip to content

Commit 8b3a057

Browse files
matteiusoz123
authored andcommitted
Add news fragment and test case
1 parent ea63719 commit 8b3a057

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

news/6306.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix issue where pipenv install would unintentionally upgrade packages that had wildcard (*) specifiers in the Pipfile, even when locked versions existed and no upgrade was requested.

tests/integration/test_install_basic.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import os
23
import re
34
import sys
@@ -740,3 +741,68 @@ def test_category_sorted_with_directive_when_insalling_with_extras(
740741
"requests",
741742
"six",
742743
]
744+
745+
746+
@pytest.mark.basic
747+
@pytest.mark.install
748+
def test_install_respects_lockfile_versions(pipenv_instance_pypi):
749+
"""Ensure that `pipenv install` respects versions from existing lockfile."""
750+
with pipenv_instance_pypi() as p:
751+
with open(p.pipfile_path, "w") as f:
752+
contents = """
753+
[[source]]
754+
url = "https://pypi.org/simple"
755+
verify_ssl = true
756+
name = "pypi"
757+
758+
[packages]
759+
sh = "*"
760+
""".strip()
761+
f.write(contents)
762+
763+
with open(p.lockfile_path, "w") as f:
764+
contents = """
765+
{
766+
"_meta": {
767+
"hash": {
768+
"sha256": "f9adf532d46f4787b6afe331abe415d5698ef7523cd6225605328b61f361d427"
769+
},
770+
"pipfile-spec": 6,
771+
"requires": {},
772+
"sources": [
773+
{
774+
"name": "pypi",
775+
"url": "https://pypi.org/simple",
776+
"verify_ssl": true
777+
}
778+
]
779+
},
780+
"default": {
781+
"sh": {
782+
"hashes": [
783+
"sha256:39aa9af22f6558a0c5d132881cf43e34828ca03e4ae11114852ca6a55c7c1d8e",
784+
"sha256:75e86a836f47de095d4531718fe8489e6f7446c75ddfa5596f632727b919ffae"
785+
],
786+
"index": "pypi",
787+
"version": "==1.14.1"
788+
}
789+
},
790+
"develop": {}
791+
}
792+
""".strip()
793+
f.write(contents)
794+
795+
c = p.pipenv("install")
796+
assert c.returncode == 0
797+
798+
# Verify that the locked version is installed, not the latest
799+
c = p.pipenv("graph --json")
800+
assert c.returncode == 0
801+
802+
graph_data = json.loads(c.stdout)
803+
for package in graph_data:
804+
if package["package"] == "sh":
805+
assert package["version"] == "1.14.1"
806+
break
807+
else:
808+
pytest.fail("sh package not found in graph output")

0 commit comments

Comments
 (0)