From bf1510d07bd1302e095297ebfd250e6a97ea83a3 Mon Sep 17 00:00:00 2001 From: "poetry-bot[bot]" <112719459+poetry-bot[bot]@users.noreply.github.com> Date: Wed, 18 Jan 2023 11:14:39 +0000 Subject: [PATCH] [1.3] poetry check command accepts --directory argument (#7365) Co-authored-by: Martin Miglio --- src/poetry/console/commands/check.py | 4 +--- tests/console/commands/test_check.py | 15 ++++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/poetry/console/commands/check.py b/src/poetry/console/commands/check.py index 30812883523..12bfc09343f 100644 --- a/src/poetry/console/commands/check.py +++ b/src/poetry/console/commands/check.py @@ -1,7 +1,5 @@ from __future__ import annotations -from pathlib import Path - from poetry.console.commands.command import Command @@ -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) diff --git a/tests/console/commands/test_check.py b/tests/console/commands/test_check.py index 1c21a80f3e5..fcdfa5d9a19 100644 --- a/tests/console/commands/test_check.py +++ b/tests/console/commands/test_check.py @@ -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()