Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
d75c5a53
Commit
d75c5a53
authored
Oct 05, 2020
by
Arun Babu Neelicattu
Committed by
finswimmer
Oct 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init: handle pyproject exceptions for existing file
Resolves: #3073
parent
c3212bef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
1 deletions
+38
-1
poetry/console/commands/init.py
+2
-1
tests/console/commands/test_init.py
+36
-0
No files found.
poetry/console/commands/init.py
View file @
d75c5a53
...
@@ -13,6 +13,7 @@ from typing import Union
...
@@ -13,6 +13,7 @@ from typing import Union
from
cleo
import
option
from
cleo
import
option
from
tomlkit
import
inline_table
from
tomlkit
import
inline_table
from
poetry.core.pyproject
import
PyProjectException
from
poetry.core.pyproject.toml
import
PyProjectTOML
from
poetry.core.pyproject.toml
import
PyProjectTOML
from
poetry.utils._compat
import
OrderedDict
from
poetry.utils._compat
import
OrderedDict
from
poetry.utils._compat
import
Path
from
poetry.utils._compat
import
Path
...
@@ -378,7 +379,7 @@ The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the
...
@@ -378,7 +379,7 @@ The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the
try
:
try
:
cwd
=
self
.
poetry
.
file
.
parent
cwd
=
self
.
poetry
.
file
.
parent
except
RuntimeError
:
except
(
PyProjectException
,
RuntimeError
)
:
cwd
=
Path
.
cwd
()
cwd
=
Path
.
cwd
()
for
requirement
in
requirements
:
for
requirement
in
requirements
:
...
...
tests/console/commands/test_init.py
View file @
d75c5a53
...
@@ -621,6 +621,42 @@ line-length = 88
...
@@ -621,6 +621,42 @@ line-length = 88
)
)
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 <you@example.com>' "
"--name 'my-package' "
"--python '^3.6' "
"--dependency foo"
,
interactive
=
False
,
)
expected
=
"""
\
[tool.poetry]
name = "my-package"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
[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
(
def
test_init_existing_pyproject_with_build_system_fails
(
tester
,
source_dir
,
init_basic_inputs
tester
,
source_dir
,
init_basic_inputs
):
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment