Skip to content

Commit

Permalink
[1.3] poetry check command accepts --directory argument (#7365)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Miglio <[email protected]>
  • Loading branch information
poetry-bot[bot] and martinmiglio authored Jan 18, 2023
1 parent 7889f70 commit bf1510d
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 bf1510d

Please sign in to comment.