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
598503ec
Commit
598503ec
authored
Oct 01, 2020
by
Arun Babu Neelicattu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
env/run: ensure all args are quoted as required
Resolves: #3013
parent
51d4b5a8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
16 deletions
+30
-16
poetry/utils/_compat.py
+9
-16
tests/utils/test_env.py
+21
-0
No files found.
poetry/utils/_compat.py
View file @
598503ec
...
@@ -46,15 +46,11 @@ PY36 = sys.version_info >= (3, 6)
...
@@ -46,15 +46,11 @@ PY36 = sys.version_info >= (3, 6)
WINDOWS
=
sys
.
platform
==
"win32"
WINDOWS
=
sys
.
platform
==
"win32"
if
PY2
:
try
:
import
pipes
from
shlex
import
quote
except
ImportError
:
shell_quote
=
pipes
.
quote
# PY2
else
:
from
pipes
import
quote
# noqa
import
shlex
shell_quote
=
shlex
.
quote
if
PY34
:
if
PY34
:
from
importlib.machinery
import
EXTENSION_SUFFIXES
from
importlib.machinery
import
EXTENSION_SUFFIXES
...
@@ -288,10 +284,7 @@ def to_str(string):
...
@@ -288,10 +284,7 @@ def to_str(string):
def
list_to_shell_command
(
cmd
):
def
list_to_shell_command
(
cmd
):
executable
=
cmd
[
0
]
return
" "
.
join
(
'"{}"'
.
format
(
token
)
if
" "
in
token
and
token
[
0
]
not
in
{
"'"
,
'"'
}
else
token
if
" "
in
executable
:
for
token
in
cmd
executable
=
'"{}"'
.
format
(
executable
)
)
cmd
[
0
]
=
executable
return
" "
.
join
(
cmd
)
tests/utils/test_env.py
View file @
598503ec
...
@@ -15,6 +15,7 @@ from poetry.core.toml.file import TOMLFile
...
@@ -15,6 +15,7 @@ from poetry.core.toml.file import TOMLFile
from
poetry.factory
import
Factory
from
poetry.factory
import
Factory
from
poetry.utils._compat
import
PY2
from
poetry.utils._compat
import
PY2
from
poetry.utils._compat
import
Path
from
poetry.utils._compat
import
Path
from
poetry.utils.env
import
GET_BASE_PREFIX
from
poetry.utils.env
import
EnvCommandError
from
poetry.utils.env
import
EnvCommandError
from
poetry.utils.env
import
EnvManager
from
poetry.utils.env
import
EnvManager
from
poetry.utils.env
import
NoCompatiblePythonVersionFound
from
poetry.utils.env
import
NoCompatiblePythonVersionFound
...
@@ -74,6 +75,26 @@ def test_virtualenvs_with_spaces_in_their_path_work_as_expected(tmp_dir, manager
...
@@ -74,6 +75,26 @@ def test_virtualenvs_with_spaces_in_their_path_work_as_expected(tmp_dir, manager
assert
venv
.
run
(
"python"
,
"-V"
,
shell
=
True
)
.
startswith
(
"Python"
)
assert
venv
.
run
(
"python"
,
"-V"
,
shell
=
True
)
.
startswith
(
"Python"
)
def
test_env_commands_with_spaces_in_their_arg_work_as_expected
(
tmp_dir
,
manager
):
venv_path
=
Path
(
tmp_dir
)
/
"Virtual Env"
manager
.
build_venv
(
str
(
venv_path
))
venv
=
VirtualEnv
(
venv_path
)
assert
venv
.
run
(
"python"
,
venv
.
pip
,
"--version"
,
shell
=
True
)
.
startswith
(
"pip {} from "
.
format
(
venv
.
pip_version
)
)
def
test_env_shell_commands_with_stdinput_in_their_arg_work_as_expected
(
tmp_dir
,
manager
):
venv_path
=
Path
(
tmp_dir
)
/
"Virtual Env"
manager
.
build_venv
(
str
(
venv_path
))
venv
=
VirtualEnv
(
venv_path
)
assert
venv
.
run
(
"python"
,
"-"
,
input_
=
GET_BASE_PREFIX
,
shell
=
True
)
.
strip
()
==
str
(
venv
.
get_base_prefix
()
)
@pytest.fixture
@pytest.fixture
def
in_project_venv_dir
(
poetry
):
def
in_project_venv_dir
(
poetry
):
os
.
environ
.
pop
(
"VIRTUAL_ENV"
,
None
)
os
.
environ
.
pop
(
"VIRTUAL_ENV"
,
None
)
...
...
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