mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
Fix quoting issue in virtualenv activator (#5700)
* add test case for directory with spaces * Stop XonshActivator from quoting strings * add news * Update fix-virtualenv-quoting.rst --------- Co-authored-by: Andy Kipp <anki-code@users.noreply.github.com>
This commit is contained in:
parent
31170c2daf
commit
4fc7d59c95
3 changed files with 41 additions and 4 deletions
23
news/fix-virtualenv-quoting.rst
Normal file
23
news/fix-virtualenv-quoting.rst
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
**Added:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Changed:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Deprecated:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Removed:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Fixed:**
|
||||||
|
|
||||||
|
* Fixed incorrect quoting behaviour in `activate.xsh` for virtualenv version 20.26.6.
|
||||||
|
|
||||||
|
**Security:**
|
||||||
|
|
||||||
|
* <news item>
|
|
@ -2,12 +2,15 @@ import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from subprocess import check_output
|
from subprocess import check_output
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from xonsh.pytest.tools import ON_WINDOWS
|
from xonsh.pytest.tools import ON_WINDOWS
|
||||||
|
|
||||||
|
|
||||||
def test_xonsh_activator(tmp_path):
|
@pytest.mark.parametrize("dir_name", ["venv", "venv with space"])
|
||||||
|
def test_xonsh_activator(tmp_path, dir_name):
|
||||||
# Create virtualenv
|
# Create virtualenv
|
||||||
venv_dir = tmp_path / "venv"
|
venv_dir = tmp_path / dir_name
|
||||||
assert b"XonshActivator" in check_output(
|
assert b"XonshActivator" in check_output(
|
||||||
[sys.executable, "-m", "virtualenv", str(venv_dir)]
|
[sys.executable, "-m", "virtualenv", str(venv_dir)]
|
||||||
)
|
)
|
||||||
|
@ -35,7 +38,13 @@ def test_xonsh_activator(tmp_path):
|
||||||
|
|
||||||
# Activate
|
# Activate
|
||||||
venv_python = check_output(
|
venv_python = check_output(
|
||||||
[sys.executable, "-m", "xonsh", "-c", f"source {activate_path}; which python"]
|
[
|
||||||
|
sys.executable,
|
||||||
|
"-m",
|
||||||
|
"xonsh",
|
||||||
|
"-c",
|
||||||
|
f"source r'{activate_path}'; which python",
|
||||||
|
]
|
||||||
).decode()
|
).decode()
|
||||||
assert Path(venv_python).parent == bin_path
|
assert Path(venv_python).parent == bin_path
|
||||||
|
|
||||||
|
@ -46,7 +55,7 @@ def test_xonsh_activator(tmp_path):
|
||||||
"-m",
|
"-m",
|
||||||
"xonsh",
|
"xonsh",
|
||||||
"-c",
|
"-c",
|
||||||
f"source {activate_path}; deactivate; "
|
f"source r'{activate_path}'; deactivate; "
|
||||||
"import shutil; shutil.which('python') or shutil.which('python3')",
|
"import shutil; shutil.which('python') or shutil.which('python3')",
|
||||||
]
|
]
|
||||||
).decode()
|
).decode()
|
||||||
|
|
|
@ -5,6 +5,11 @@ class XonshActivator(ViaTemplateActivator):
|
||||||
def templates(self):
|
def templates(self):
|
||||||
yield "activate.xsh"
|
yield "activate.xsh"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def quote(string):
|
||||||
|
# leave string unchanged since we do quoting in activate.xsh (see #5699)
|
||||||
|
return string
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def supports(cls, interpreter):
|
def supports(cls, interpreter):
|
||||||
return interpreter.version_info >= (3, 5)
|
return interpreter.version_info >= (3, 5)
|
||||||
|
|
Loading…
Add table
Reference in a new issue