Skip to content

Commit

Permalink
fix(check): don't raise error on pypi reference
Browse files Browse the repository at this point in the history
  • Loading branch information
Secrus committed Aug 2, 2024
1 parent b6bad9c commit 3c2462c
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/poetry/console/commands/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def _validate_readme(self, readme: str | list[str], poetry_file: Path) -> list[s
def _validate_dependencies_source(self, config: dict[str, Any]) -> list[str]:
"""Check dependencies's source are valid"""
sources = {k["name"] for k in config.get("source", [])}
sources.add("pypi")

dependency_declarations: list[
dict[str, str | dict[str, str] | list[dict[str, str]]]
Expand Down
20 changes: 20 additions & 0 deletions tests/console/commands/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ def poetry_with_up_to_date_lockfile(
yield Factory().create_poetry(cwd)


@pytest.fixture
def poetry_with_pypi_reference(
set_project_context: SetProjectContext,
) -> Iterator[Poetry]:
with set_project_context("pypi_reference", in_place=False) as cwd:
yield Factory().create_poetry(cwd)


@pytest.fixture()
def tester(
command_tester_factory: CommandTesterFactory, poetry_sample_project: Poetry
Expand Down Expand Up @@ -210,3 +218,15 @@ def test_check_lock_up_to_date(

# exit with an error
assert status_code == 0


def test_check_does_not_error_on_pypi_reference(
command_tester_factory: CommandTesterFactory,
poetry_with_pypi_reference: Poetry,
) -> None:
tester = command_tester_factory("check", poetry=poetry_with_pypi_reference)
status_code = tester.execute("")
expected = "All set!\n"

assert tester.io.fetch_output() == expected
assert status_code == 0
143 changes: 143 additions & 0 deletions tests/fixtures/pypi_reference/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions tests/fixtures/pypi_reference/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[tool.poetry]
name = "foobar"
version = "0.1.0"
description = ""
authors = ["Poetry Developer <developer@python-poetry.org>"]

[tool.poetry.dependencies]
python = "^3.8"
docker = { version = ">=4.3.1", source = "pypi" }

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

0 comments on commit 3c2462c

Please sign in to comment.