-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init: handle pyproject exceptions for existing file
Resolves: #3073
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -621,6 +621,42 @@ def test_init_existing_pyproject_simple( | |
) | ||
|
||
|
||
def test_init_non_interactive_existing_pyproject_add_dependency( | ||
tester, source_dir, init_basic_inputs, repo | ||
): | ||
pyproject_file = source_dir / "pyproject.toml" | ||
existing_section = """ | ||
[tool.black] | ||
line-length = 88 | ||
""" | ||
pyproject_file.write_text(decode(existing_section)) | ||
|
||
repo.add_package(get_package("foo", "1.19.2")) | ||
|
||
tester.execute( | ||
"--author 'Your Name <[email protected]>' " | ||
"--name 'my-package' " | ||
"--python '^3.6' " | ||
"--dependency foo", | ||
interactive=False, | ||
) | ||
|
||
expected = """\ | ||
[tool.poetry] | ||
name = "my-package" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["Your Name <[email protected]>"] | ||
[tool.poetry.dependencies] | ||
python = "^3.6" | ||
foo = "^1.19.2" | ||
[tool.poetry.dev-dependencies] | ||
""" | ||
assert "{}\n{}".format(existing_section, expected) in pyproject_file.read_text() | ||
|
||
|
||
def test_init_existing_pyproject_with_build_system_fails( | ||
tester, source_dir, init_basic_inputs | ||
): | ||
|