Skip to content

Commit

Permalink
poetry check command accepts --directory argument (#7241)
Browse files Browse the repository at this point in the history
(cherry picked from commit 2d54ec9)
  • Loading branch information
martinmiglio authored and github-actions[bot] committed Jan 18, 2023
1 parent 7889f70 commit 1718f50
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/poetry/console/commands/check.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

from pathlib import Path

from poetry.console.commands.command import Command


Expand Down Expand Up @@ -61,7 +59,7 @@ def handle(self) -> int:
from poetry.factory import Factory

# Load poetry config and display errors, if any
poetry_file = Factory.locate(Path.cwd())
poetry_file = self.poetry.file.path
config = PyProjectTOML(poetry_file).poetry_config
check_result = Factory.validate(config, strict=True)

Expand Down
15 changes: 10 additions & 5 deletions tests/console/commands/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ def test_check_valid(tester: CommandTester):


def test_check_invalid(mocker: MockerFixture, tester: CommandTester):
from poetry.core.toml import TOMLFile

mocker.patch(
"poetry.factory.Factory.locate",
return_value=Path(__file__).parent.parent.parent
/ "fixtures"
/ "invalid_pyproject"
/ "pyproject.toml",
"poetry.poetry.Poetry.file",
return_value=TOMLFile(
Path(__file__).parent.parent.parent
/ "fixtures"
/ "invalid_pyproject"
/ "pyproject.toml"
),
new_callable=mocker.PropertyMock,
)

tester.execute()
Expand Down

0 comments on commit 1718f50

Please sign in to comment.