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
11 changes: 11 additions & 0 deletions src/poetry/console/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from poetry.console.commands.command import Command
from poetry.console.commands.env_command import EnvCommand
from poetry.factory import Factory
from poetry.utils.dependency_specification import RequirementsParser
from poetry.utils.env.python import Python

Expand Down Expand Up @@ -268,6 +269,16 @@ def _init_pyproject(

return 1

# Validate fields before creating pyproject.toml file. If any validations fail, throw an error.
validation_results = Factory().validate(pyproject.data)
if validation_results.get("errors"):
message = ""
for error in validation_results.get("errors", []):
message += f" - {error}\n"

self.line_error(f"Validation failed: \n{message}")
return 1

pyproject.save()

if create_layout:
Expand Down
29 changes: 29 additions & 0 deletions tests/console/commands/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@
"""
pyproject_file.write_text(existing_section, encoding="utf-8")
tester.execute(inputs=init_basic_inputs)
assert f"{existing_section}\n{init_basic_toml}" in pyproject_file.read_text(

Check failure on line 921 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.11) / pytest

test_init_existing_pyproject_simple assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/private/var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/pytest-of-runner/pytest-0/popen-gw2/test_init_existing_pyproject_s0/pyproject.toml').read_text

Check failure on line 921 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.13) / pytest

test_init_existing_pyproject_simple assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/tmp/pytest-of-runner/pytest-0/popen-gw1/test_init_existing_pyproject_s0/pyproject.toml').read_text

Check failure on line 921 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.10) / pytest

test_init_existing_pyproject_simple assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/private/var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/pytest-of-runner/pytest-0/popen-gw1/test_init_existing_pyproject_s0/pyproject.toml').read_text

Check failure on line 921 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.11) / pytest

test_init_existing_pyproject_simple assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/tmp/pytest-of-runner/pytest-0/popen-gw1/test_init_existing_pyproject_s0/pyproject.toml').read_text

Check failure on line 921 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.12) / pytest

test_init_existing_pyproject_simple assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/tmp/pytest-of-runner/pytest-0/popen-gw2/test_init_existing_pyproject_s0/pyproject.toml').read_text

Check failure on line 921 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.10) / pytest

test_init_existing_pyproject_simple assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/tmp/pytest-of-runner/pytest-0/popen-gw1/test_init_existing_pyproject_s0/pyproject.toml').read_text

Check failure on line 921 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.12) / pytest

test_init_existing_pyproject_simple assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/private/var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/pytest-of-runner/pytest-0/popen-gw0/test_init_existing_pyproject_s0/pyproject.toml').read_text

Check failure on line 921 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.9) / pytest

test_init_existing_pyproject_simple assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/tmp/pytest-of-runner/pytest-0/popen-gw2/test_init_existing_pyproject_s0/pyproject.toml').read_text

Check failure on line 921 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.13) / pytest

test_init_existing_pyproject_simple assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/private/var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/pytest-of-runner/pytest-0/popen-gw2/test_init_existing_pyproject_s0/pyproject.toml').read_text

Check failure on line 921 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.9) / pytest

test_init_existing_pyproject_simple assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/private/var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/pytest-of-runner/pytest-0/popen-gw2/test_init_existing_pyproject_s0/pyproject.toml').read_text
encoding="utf-8"
)

Expand All @@ -942,7 +942,7 @@
with open(pyproject_file, newline="", encoding="utf-8") as f:
content = f.read()
init_basic_toml = init_basic_toml.replace("\n", linesep)
assert f"{existing_section}{linesep}{init_basic_toml}" in content

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.11) / pytest

test_init_existing_pyproject_consistent_linesep[\r\n] assert '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\n' in '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[tool.poetry]\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\ndependencies = [\r\n]\r\n\r\n\r\n[build-system]\r\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\r\nbuild-backend = "poetry.core.masonry.api"\r\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.11) / pytest

test_init_existing_pyproject_consistent_linesep[\n] assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.13) / pytest

test_init_existing_pyproject_consistent_linesep[\r\n] assert '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\n' in '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[tool.poetry]\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\ndependencies = [\r\n]\r\n\r\n\r\n[build-system]\r\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\r\nbuild-backend = "poetry.core.masonry.api"\r\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.13) / pytest

test_init_existing_pyproject_consistent_linesep[\n] assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.10) / pytest

test_init_existing_pyproject_consistent_linesep[\n] assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.10) / pytest

test_init_existing_pyproject_consistent_linesep[\r\n] assert '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\n' in '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[tool.poetry]\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\ndependencies = [\r\n]\r\n\r\n\r\n[build-system]\r\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\r\nbuild-backend = "poetry.core.masonry.api"\r\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.11) / pytest

test_init_existing_pyproject_consistent_linesep[\n] assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.11) / pytest

test_init_existing_pyproject_consistent_linesep[\r\n] assert '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\n' in '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[tool.poetry]\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\ndependencies = [\r\n]\r\n\r\n\r\n[build-system]\r\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\r\nbuild-backend = "poetry.core.masonry.api"\r\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.12) / pytest

test_init_existing_pyproject_consistent_linesep[\n] assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.12) / pytest

test_init_existing_pyproject_consistent_linesep[\r\n] assert '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\n' in '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[tool.poetry]\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\ndependencies = [\r\n]\r\n\r\n\r\n[build-system]\r\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\r\nbuild-backend = "poetry.core.masonry.api"\r\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.10) / pytest

test_init_existing_pyproject_consistent_linesep[\r\n] assert '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\n' in '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[tool.poetry]\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\ndependencies = [\r\n]\r\n\r\n\r\n[build-system]\r\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\r\nbuild-backend = "poetry.core.masonry.api"\r\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.10) / pytest

test_init_existing_pyproject_consistent_linesep[\n] assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.12) / pytest

test_init_existing_pyproject_consistent_linesep[\n] assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.12) / pytest

test_init_existing_pyproject_consistent_linesep[\r\n] assert '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\n' in '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[tool.poetry]\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\ndependencies = [\r\n]\r\n\r\n\r\n[build-system]\r\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\r\nbuild-backend = "poetry.core.masonry.api"\r\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.9) / pytest

test_init_existing_pyproject_consistent_linesep[\r\n] assert '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\n' in '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[tool.poetry]\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\ndependencies = [\r\n]\r\n\r\n\r\n[build-system]\r\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\r\nbuild-backend = "poetry.core.masonry.api"\r\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.9) / pytest

test_init_existing_pyproject_consistent_linesep[\n] assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.13) / pytest

test_init_existing_pyproject_consistent_linesep[\n] assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.13) / pytest

test_init_existing_pyproject_consistent_linesep[\r\n] assert '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\n' in '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[tool.poetry]\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\ndependencies = [\r\n]\r\n\r\n\r\n[build-system]\r\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\r\nbuild-backend = "poetry.core.masonry.api"\r\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.9) / pytest

test_init_existing_pyproject_consistent_linesep[\n] assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "1.2.3"\ndescription = "This is a description"\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nlicense = {text = "MIT"}\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n'

Check failure on line 945 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.9) / pytest

test_init_existing_pyproject_consistent_linesep[\r\n] assert '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\n' in '\r\n[tool.black]\r\nline-length = 88\r\n\r\n[tool.poetry]\r\n\r\n[project]\r\nname = "my-package"\r\nversion = "1.2.3"\r\ndescription = "This is a description"\r\nauthors = [\r\n {name = "Your Name",email = "[email protected]"}\r\n]\r\nlicense = {text = "MIT"}\r\nreadme = "README.md"\r\nrequires-python = ">=3.6"\r\ndependencies = [\r\n]\r\n\r\n\r\n[build-system]\r\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\r\nbuild-backend = "poetry.core.masonry.api"\r\n'


def test_init_non_interactive_existing_pyproject_add_dependency(
Expand Down Expand Up @@ -982,7 +982,7 @@
"foo (>=1.19.2,<2.0.0)"
]
"""
assert f"{existing_section}\n{expected}" in pyproject_file.read_text(

Check failure on line 985 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.11) / pytest

test_init_non_interactive_existing_pyproject_add_dependency assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/private/var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/pytest-of-runner/pytest-0/popen-gw1/test_init_non_interactive_exis0/pyproject.toml').read_text

Check failure on line 985 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.13) / pytest

test_init_non_interactive_existing_pyproject_add_dependency assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/tmp/pytest-of-runner/pytest-0/popen-gw1/test_init_non_interactive_exis0/pyproject.toml').read_text

Check failure on line 985 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.10) / pytest

test_init_non_interactive_existing_pyproject_add_dependency assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/private/var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/pytest-of-runner/pytest-0/popen-gw1/test_init_non_interactive_exis0/pyproject.toml').read_text

Check failure on line 985 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.11) / pytest

test_init_non_interactive_existing_pyproject_add_dependency assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/tmp/pytest-of-runner/pytest-0/popen-gw1/test_init_non_interactive_exis0/pyproject.toml').read_text

Check failure on line 985 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.12) / pytest

test_init_non_interactive_existing_pyproject_add_dependency assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/tmp/pytest-of-runner/pytest-0/popen-gw0/test_init_non_interactive_exis0/pyproject.toml').read_text

Check failure on line 985 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.10) / pytest

test_init_non_interactive_existing_pyproject_add_dependency assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/tmp/pytest-of-runner/pytest-0/popen-gw1/test_init_non_interactive_exis0/pyproject.toml').read_text

Check failure on line 985 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.12) / pytest

test_init_non_interactive_existing_pyproject_add_dependency assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/private/var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/pytest-of-runner/pytest-0/popen-gw0/test_init_non_interactive_exis0/pyproject.toml').read_text

Check failure on line 985 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / Ubuntu (Python 3.9) / pytest

test_init_non_interactive_existing_pyproject_add_dependency assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/tmp/pytest-of-runner/pytest-0/popen-gw2/test_init_non_interactive_exis0/pyproject.toml').read_text

Check failure on line 985 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.13) / pytest

test_init_non_interactive_existing_pyproject_add_dependency assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/private/var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/pytest-of-runner/pytest-0/popen-gw2/test_init_non_interactive_exis0/pyproject.toml').read_text

Check failure on line 985 in tests/console/commands/test_init.py

View workflow job for this annotation

GitHub Actions / macOS aarch64 (Python 3.9) / pytest

test_init_non_interactive_existing_pyproject_add_dependency assert '\n[tool.black]\nline-length = 88\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n' in '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' + where '\n[tool.black]\nline-length = 88\n\n[tool.poetry]\n\n[project]\nname = "my-package"\nversion = "0.1.0"\ndescription = ""\nauthors = [\n {name = "Your Name",email = "[email protected]"}\n]\nreadme = "README.md"\nrequires-python = ">=3.6"\ndependencies = [\n "foo (>=1.19.2,<2.0.0)"\n]\n\n\n[build-system]\nrequires = ["poetry-core>=2.0.0,<3.0.0"]\nbuild-backend = "poetry.core.masonry.api"\n' = read_text(encoding='utf-8') + where read_text = PosixPath('/private/var/folders/y6/nj790rtn62lfktb1sh__79hc0000gn/T/pytest-of-runner/pytest-0/popen-gw2/test_init_non_interactive_exis0/pyproject.toml').read_text
encoding="utf-8"
)

Expand Down Expand Up @@ -1207,3 +1207,32 @@
# Existing files should remain
assert (source_dir / "existing_file.txt").exists()
assert (source_dir / "existing_dir").exists()


def test_noninteractive_validation_shows_error(
app: PoetryTestApplication, mocker: MockerFixture
) -> None:
command = app.find("init")
assert isinstance(command, InitCommand)

expected_error = r"Validation failed: \n - project.name must match pattern ^([a-zA-Z\d]|[a-zA-Z\d][\w.-]*[a-zA-Z\d])$"

# Set Factory.validate to return a mocked error message
# We mock Factory.validate() because this test focuses on _init_pyproject(), not on the validation logic itself.
mocked_validate = mocker.patch(
"poetry.console.commands.init.Factory.validate",
return_value={"errors": [expected_error]},
)

init_tester = CommandTester(command)
args = '--name "new project"'
result = init_tester.execute(args=args, interactive=False)

# Check that the command fails
assert result == 1

error_output = init_tester.io.fetch_error()
assert expected_error in error_output

# Verify that validate() was called
mocked_validate.assert_called_once()
Loading