Skip to content

Commit 29a4564

Browse files
committed
pip lock: add basic test
1 parent 0ee4f0c commit 29a4564

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/functional/test_lock.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import sys
2+
from pathlib import Path
3+
4+
from pip._internal.utils.urls import path_to_url
5+
6+
from ..lib import PipTestEnvironment, TestData
7+
8+
if sys.version_info >= (3, 11):
9+
import tomllib
10+
else:
11+
from pip._vendor import tomli as tomllib
12+
13+
14+
def test_lock_basic(
15+
script: PipTestEnvironment, shared_data: TestData, tmp_path: Path
16+
) -> None:
17+
result = script.pip(
18+
"lock",
19+
"simplewheel",
20+
"--no-index",
21+
"--find-links",
22+
str(shared_data.root / "packages/"),
23+
expect_stderr=True, # for the experimental warning
24+
)
25+
result.did_create(Path("scratch") / "pylock.toml")
26+
pylock = tomllib.loads(script.scratch_path.joinpath("pylock.toml").read_text())
27+
assert pylock["lock-version"] == "1.0"
28+
assert pylock["created-by"] == "pip"
29+
assert len(pylock["packages"]) == 1
30+
package = pylock["packages"][0]
31+
assert package["name"] == "simplewheel"
32+
assert package["version"] == "2.0"
33+
assert package["wheels"][0]["name"] == "simplewheel-2.0-1-py2.py3-none-any.whl"
34+
assert package["wheels"][0]["url"] == path_to_url(
35+
str(shared_data.root / "packages/simplewheel-2.0-1-py2.py3-none-any.whl")
36+
)
37+
assert package["wheels"][0]["hashes"]["sha256"] == (
38+
"71e1ca6b16ae3382a698c284013f66504f2581099b2ce4801f60e9536236ceee"
39+
)

0 commit comments

Comments
 (0)