forked from python-poetry/poetry
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deprecate
install --sync
and introduce self sync command
for symm…
…etry
- Loading branch information
Showing
8 changed files
with
251 additions
and
33 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
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
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,31 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
from typing import ClassVar | ||
|
||
from poetry.console.commands.self.install import SelfInstallCommand | ||
|
||
|
||
if TYPE_CHECKING: | ||
from cleo.io.inputs.option import Option | ||
|
||
|
||
class SelfSyncCommand(SelfInstallCommand): | ||
name = "self sync" | ||
description = ( | ||
"Sync Poetry's own environment according to the locked packages (incl. addons)" | ||
" required by this Poetry installation." | ||
) | ||
options: ClassVar[list[Option]] = [ | ||
opt for opt in SelfInstallCommand.options if opt.name != "sync" | ||
] | ||
help = f"""\ | ||
The <c1>self sync</c1> command ensures all additional (and no other) packages \ | ||
specified are installed in the current runtime environment. | ||
This is managed in the \ | ||
<comment>{SelfInstallCommand.get_default_system_pyproject_file()}</> file. | ||
You can add more packages using the <c1>self add</c1> command and remove them using \ | ||
the <c1>self remove</c1> command. | ||
""" |
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,30 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import pytest | ||
|
||
from cleo.exceptions import CleoNoSuchOptionError | ||
|
||
# import all tests from the self install command | ||
# and run them for sync by overriding the command fixture | ||
from tests.console.commands.self.test_install import * # noqa: F403 | ||
|
||
|
||
if TYPE_CHECKING: | ||
from cleo.testers.command_tester import CommandTester | ||
|
||
|
||
@pytest.fixture # type: ignore[no-redef] | ||
def command() -> str: | ||
return "self sync" | ||
|
||
|
||
@pytest.mark.skip("Only relevant for `poetry self install`") # type: ignore[no-redef] | ||
def test_sync_deprecation() -> None: | ||
"""The only test from the self install command that does not work for self sync.""" | ||
|
||
|
||
def test_sync_option_not_available(tester: CommandTester) -> None: | ||
with pytest.raises(CleoNoSuchOptionError): | ||
tester.execute("--sync") |
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