Skip to content

Commit 9bcf663

Browse files
committed
test(installer): use locked version of vcs dependency without reference (branch, tag, rev) instead of latest
Requires: python-poetry/poetry-core#449
1 parent a4d4cad commit 9bcf663

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[[package]]
2+
name = "demo"
3+
version = "0.1.2"
4+
description = ""
5+
category = "main"
6+
optional = false
7+
python-versions = "*"
8+
develop = false
9+
10+
[package.dependencies]
11+
pendulum = ">=1.4.4"
12+
13+
[package.source]
14+
type = "git"
15+
url = "https://github.com/demo/demo.git"
16+
reference = "HEAD"
17+
resolved_reference = "123456"
18+
19+
[[package]]
20+
name = "pendulum"
21+
version = "1.4.4"
22+
description = ""
23+
category = "main"
24+
optional = false
25+
python-versions = "*"
26+
27+
[metadata]
28+
python-versions = "*"
29+
lock-version = "1.1"
30+
content-hash = "123456789"
31+
32+
[metadata.files]
33+
demo = []
34+
pendulum = []

tests/installation/test_installer.py

+38
Original file line numberDiff line numberDiff line change
@@ -2516,3 +2516,41 @@ def test_installer_should_use_the_locked_version_of_git_dependencies_with_extras
25162516
source_reference="master",
25172517
source_resolved_reference=expected_reference,
25182518
)
2519+
2520+
2521+
@pytest.mark.parametrize("is_locked", [False, True])
2522+
def test_installer_should_use_the_locked_version_of_git_dependencies_without_reference(
2523+
installer: Installer,
2524+
locker: Locker,
2525+
package: ProjectPackage,
2526+
repo: Repository,
2527+
is_locked: bool,
2528+
):
2529+
"""
2530+
If there is no explicit reference (branch or tag or rev) in pyproject.toml,
2531+
HEAD is used.
2532+
"""
2533+
if is_locked:
2534+
locker.locked(True)
2535+
locker.mock_lock_data(fixture("with-vcs-dependency-without-ref"))
2536+
expected_reference = "123456"
2537+
else:
2538+
expected_reference = MOCK_DEFAULT_GIT_REVISION
2539+
2540+
package.add_dependency(
2541+
Factory.create_dependency("demo", {"git": "https://github.com/demo/demo.git"})
2542+
)
2543+
2544+
repo.add_package(get_package("pendulum", "1.4.4"))
2545+
2546+
installer.run()
2547+
2548+
assert len(installer.executor.installations) == 2
2549+
assert installer.executor.installations[-1] == Package(
2550+
"demo",
2551+
"0.1.2",
2552+
source_type="git",
2553+
source_url="https://github.com/demo/demo.git",
2554+
source_reference="HEAD",
2555+
source_resolved_reference=expected_reference,
2556+
)

0 commit comments

Comments
 (0)