mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 06:46:15 +00:00
Merge pull request #2415 from dnoetzel/bugfix-439
Allow virtual env creation in dir with leading dash
This commit is contained in:
+2
-1
@@ -911,7 +911,6 @@ def do_create_virtualenv(python=None, site_packages=False):
|
||||
'-m',
|
||||
'pipenv.pew',
|
||||
'new',
|
||||
project.virtualenv_name,
|
||||
'-d',
|
||||
'-a',
|
||||
project.project_directory,
|
||||
@@ -929,6 +928,8 @@ def do_create_virtualenv(python=None, site_packages=False):
|
||||
err=True,
|
||||
)
|
||||
cmd = cmd + ['-p', python]
|
||||
if not project.is_venv_in_project():
|
||||
cmd = cmd + ['--', project.virtualenv_name]
|
||||
# Actually create the virtualenv.
|
||||
with spinner():
|
||||
try:
|
||||
|
||||
@@ -2,11 +2,20 @@
|
||||
|
||||
XXX: Try our best to reduce tests in this file.
|
||||
"""
|
||||
import os
|
||||
from tempfile import gettempdir, mkdtemp
|
||||
|
||||
import mock
|
||||
import pytest
|
||||
|
||||
from pipenv.core import activate_virtualenv
|
||||
from pipenv.project import Project
|
||||
from pipenv.vendor import delegator
|
||||
import pytest
|
||||
|
||||
try:
|
||||
from pathlib import Path
|
||||
except ImportError:
|
||||
from pipenv.vendor.pathlib2 import Path
|
||||
|
||||
|
||||
@pytest.mark.code
|
||||
@@ -92,3 +101,26 @@ def test_proper_names_unamanged_virtualenv(PipenvInstance, pypi):
|
||||
assert c.return_code == 0
|
||||
project = Project()
|
||||
assert project.proper_names == []
|
||||
|
||||
|
||||
@pytest.mark.cli
|
||||
def test_directory_with_leading_dash(PipenvInstance):
|
||||
def mocked_mkdtemp(suffix, prefix, dir):
|
||||
if suffix == '-project':
|
||||
temp_dir = Path(gettempdir()) / '-dir-with-leading-dash'
|
||||
temp_dir.mkdir()
|
||||
return str(temp_dir)
|
||||
else:
|
||||
return mkdtemp(suffix, prefix, dir)
|
||||
|
||||
with mock.patch('pipenv._compat.mkdtemp', side_effect=mocked_mkdtemp):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
# This environment variable is set in the context manager and will
|
||||
# cause pipenv to use virtualenv, not pew.
|
||||
del os.environ['PIPENV_VENV_IN_PROJECT']
|
||||
p.pipenv('--python python')
|
||||
venv_path = p.pipenv('--venv').out.strip()
|
||||
assert os.path.isdir(venv_path)
|
||||
# Manually clean up environment, since PipenvInstance assumes that
|
||||
# the virutalenv is in the project directory.
|
||||
p.pipenv('--rm')
|
||||
Reference in New Issue
Block a user