-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lock: resolve dependencies on no-update
This change ensures that we resolve dependencies to correctly propagate markers when using `lock --no-update`. Resolves: #3048
- Loading branch information
1 parent
349e0dd
commit f7a55f4
Showing
7 changed files
with
390 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import shutil | ||
import sys | ||
|
||
import pytest | ||
|
||
from poetry.factory import Factory | ||
from poetry.packages import Locker | ||
from poetry.utils._compat import Path | ||
|
||
|
||
@pytest.fixture | ||
def source_dir(tmp_path): # type: (Path) -> Path | ||
yield Path(tmp_path.as_posix()) | ||
|
||
|
||
@pytest.fixture | ||
def tester(command_tester_factory): | ||
return command_tester_factory("lock") | ||
|
||
|
||
@pytest.fixture | ||
def poetry_with_old_lockfile(fixture_dir, source_dir): | ||
project_dir = source_dir / "project" | ||
shutil.copytree(str(fixture_dir("old_lock")), str(project_dir)) | ||
poetry = Factory().create_poetry(cwd=project_dir) | ||
return poetry | ||
|
||
|
||
@pytest.mark.skipif( | ||
sys.platform == "win32", reason="does not work on windows under ci environments" | ||
) | ||
def test_lock_no_update(command_tester_factory, poetry_with_old_lockfile, http): | ||
http.disable() | ||
|
||
locked_repository = poetry_with_old_lockfile.locker.locked_repository( | ||
with_dev_reqs=True | ||
) | ||
assert ( | ||
poetry_with_old_lockfile.locker.lock_data["metadata"].get("lock-version") | ||
== "1.0" | ||
) | ||
|
||
tester = command_tester_factory("lock", poetry=poetry_with_old_lockfile) | ||
tester.execute("--no-update") | ||
|
||
locker = Locker( | ||
lock=poetry_with_old_lockfile.pyproject.file.path.parent / "poetry.lock", | ||
local_config={}, | ||
) | ||
packages = locker.locked_repository(True).packages | ||
|
||
assert len(packages) == len(locked_repository.packages) | ||
|
||
assert locker.lock_data["metadata"].get("lock-version") == "1.1" | ||
|
||
for package in packages: | ||
assert locked_repository.find_packages(package.to_dependency()) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[tool.poetry] | ||
name = "foobar" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["Poetry Developer <developer@python-poetry.org>"] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.8" | ||
docker = "^4.3.1" | ||
|
||
[tool.poetry.dev-dependencies] | ||
|
||
[build-system] | ||
requires = ["poetry-core>=1.0.0"] | ||
build-backend = "poetry.core.masonry.api" |
Oops, something went wrong.