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.
6565
6666Syntax::
6767
68- mktmpenv [ENVNAME ]
68+ mktmpenv [VIRTUALENV_OPTIONS ]
6969
70- If no environment name is given, a temporary unique name is generated.
70+ A unique virtualenv name is generated.
7171
7272::
7373
Original file line number Diff line number Diff line change 22Release History
33===============
44
5+ dev
6+
7+ - Changed arguments to :ref: `command-mktmpenv ` so it always creates
8+ an environment name for you. (:bbissue: `114 `)
9+
5102.10
611
712 - 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() {
2828}
2929
3030test_mktmpenv_name () {
31- assertFalse " Environment already exists" " [ -d \" $WORKON_HOME /name-given-by-user\" ]"
3231 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 ]"
3540}
3641
3742test_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 " )
4246 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 \" ]"
4448}
4549
4650. " $test_dir /shunit2"
Original file line number Diff line number Diff line change @@ -915,22 +915,18 @@ function cdproject {
915915#
916916mktmpenv () {
917917 typeset tmpenvname
918+ typeset RC
918919
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 " ]
921923 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)
931926 fi
932927
933928 # Create the environment
929+ mkvirtualenv " $@ " " $tmpenvname "
934930 RC=$?
935931 if [ $RC -ne 0 ]
936932 then
You can’t perform that action at this time.
0 commit comments