File tree Expand file tree Collapse file tree 4 files changed +26
-21
lines changed Expand file tree Collapse file tree 4 files changed +26
-21
lines changed Original file line number Diff line number Diff line change @@ -65,9 +65,9 @@ Create a new virtualenv in the ``WORKON_HOME`` directory.
65
65
66
66
Syntax::
67
67
68
- mktmpenv [ENVNAME ]
68
+ mktmpenv [VIRTUALENV_OPTIONS ]
69
69
70
- If no environment name is given, a temporary unique name is generated.
70
+ A unique virtualenv name is generated.
71
71
72
72
::
73
73
Original file line number Diff line number Diff line change 2
2
Release History
3
3
===============
4
4
5
+ dev
6
+
7
+ - Changed arguments to :ref: `command-mktmpenv ` so it always creates
8
+ an environment name for you. (:bbissue: `114 `)
9
+
5
10
2.10
6
11
7
12
- Incorporated patch to add ``-d `` option to
Original file line number Diff line number Diff line change @@ -28,19 +28,23 @@ test_mktmpenv_no_name() {
28
28
}
29
29
30
30
test_mktmpenv_name () {
31
- assertFalse " Environment already exists" " [ -d \" $WORKON_HOME /name-given-by-user\" ]"
32
31
mktmpenv name-given-by-user > /dev/null 2>&1
33
- assertTrue " Environment was not created" " [ -d \" $WORKON_HOME /name-given-by-user\" ]"
34
- assertSame $( basename " $VIRTUAL_ENV " ) " name-given-by-user"
32
+ RC=$?
33
+ assertTrue " Error was not detected" " [ $RC -ne 0 ]"
34
+ }
35
+
36
+ test_mktmpenv_virtualenv_args () {
37
+ mktmpenv --no-site-packages > /dev/null 2>&1
38
+ RC=$?
39
+ assertTrue " Error was detected" " [ $RC -eq 0 ]"
35
40
}
36
41
37
42
test_deactivate () {
38
- assertFalse " Environment already exists" " [ -d \" $WORKON_HOME /automatically-deleted\" ]"
39
- mktmpenv automatically-deleted > /dev/null 2>&1
40
- assertSame $( basename " $VIRTUAL_ENV " ) " automatically-deleted"
41
- assertTrue " Environment was not created" " [ -d \" $WORKON_HOME /automatically-deleted\" ]"
43
+ mktmpenv > /dev/null 2>&1
44
+ assertTrue " Environment was not created" " [ ! -z \" $VIRTUAL_ENV \" ]"
45
+ env_name=$( basename " $VIRTUAL_ENV " )
42
46
deactivate > /dev/null 2>&1
43
- assertFalse " Environment still exists" " [ -d \" $WORKON_HOME /automatically-deleted \" ]"
47
+ assertFalse " Environment still exists" " [ -d \" $WORKON_HOME /$env_name \" ]"
44
48
}
45
49
46
50
. " $test_dir /shunit2"
Original file line number Diff line number Diff line change @@ -915,22 +915,18 @@ function cdproject {
915
915
#
916
916
mktmpenv () {
917
917
typeset tmpenvname
918
+ typeset RC
918
919
919
- # Generate a unique temporary name, if one is not given.
920
- if [ $# -eq 0 ]
920
+ # Generate a unique temporary name
921
+ tmpenvname=$( " $VIRTUALENVWRAPPER_PYTHON " -c ' import uuid; print uuid.uuid4()' 2> /dev/null)
922
+ if [ -z " $tmpenvname " ]
921
923
then
922
- tmpenvname=$( " $VIRTUALENVWRAPPER_PYTHON " -c ' import uuid; print uuid.uuid4()' 2> /dev/null)
923
- if [ -z " $tmpenvname " ]
924
- then
925
- # This python does not support uuid
926
- tmpenvname=$( " $VIRTUALENVWRAPPER_PYTHON " -c ' import random; print hex(random.getrandbits(64))[2:-1]' 2> /dev/null)
927
- fi
928
- mkvirtualenv " $tmpenvname "
929
- else
930
- mkvirtualenv " $@ "
924
+ # This python does not support uuid
925
+ tmpenvname=$( " $VIRTUALENVWRAPPER_PYTHON " -c ' import random; print hex(random.getrandbits(64))[2:-1]' 2> /dev/null)
931
926
fi
932
927
933
928
# Create the environment
929
+ mkvirtualenv " $@ " " $tmpenvname "
934
930
RC=$?
935
931
if [ $RC -ne 0 ]
936
932
then
You can’t perform that action at this time.
0 commit comments