Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/poetry/core/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def _configure_entry_points(

if scripts := project.get("scripts"):
entry_points["console-scripts"] = scripts
elif scripts := tool_poetry.get("scripts"):
elif "scripts" not in project and (scripts := tool_poetry.get("scripts")):
for name, specification in scripts.items():
if isinstance(specification, str):
specification = {"reference": specification, "type": "console"}
Expand Down
25 changes: 25 additions & 0 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,31 @@ def test_create_poetry_empty_static_classifiers(
assert poetry.package.all_classifiers == []


@pytest.mark.parametrize("scripts", [None, "{}", '{current = "foo:current"}'])
@pytest.mark.parametrize(
"legacy_script",
['"foo:legacy"', '{reference = "foo:legacy", type = "console"}'],
)
def test_create_poetry_console_scripts(
scripts: str | None, legacy_script: str, tmp_path: Path
) -> None:
content = '[project]\nname = "foo"\nversion = "1"\n'
if scripts is not None:
content += f"scripts = {scripts}\n"
content += f"[tool.poetry.scripts]\nlegacy = {legacy_script}\n"
(tmp_path / "pyproject.toml").write_text(content, encoding="utf-8")

poetry = Factory().create_poetry(tmp_path)

if scripts is None:
expected = {"console-scripts": {"legacy": "foo:legacy"}}
elif scripts == "{}":
expected = {}
else:
expected = {"console-scripts": {"current": "foo:current"}}
assert poetry.package.entry_points == expected


def test_create_poetry_inline_readme_text(tmp_path: Path) -> None:
pyproject = tmp_path / "pyproject.toml"
pyproject.write_text(
Expand Down
Loading