Skip to content

Commit e175d9a

Browse files
committed
fix verification in navigation functions and add tests
1 parent a139f21 commit e175d9a

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed

README

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,30 +92,39 @@ activated.
9292
$WORKON_HOME/prermvirtualenv
9393
============================
9494

95-
The ``prermvirtualenv`` script is run as an external program before the environment is removed. The full path to the environment directory is passed as an argument to the script.
95+
The ``prermvirtualenv`` script is run as an external program before the environment is
96+
removed. The full path to the environment directory is passed as an argument to the script.
9697

9798
$WORKON_HOME/postrmvirtualenv
9899
=============================
99100

100-
The ``postrmvirtualenv`` script is run as an external program after the environment is removed. The full path to the environment directory is passed as an argument to the script.
101+
The ``postrmvirtualenv`` script is run as an external program after the environment is
102+
removed. The full path to the environment directory is passed as an argument to the script.
101103

102104
===============
103105
Path Management
104106
===============
105107

106-
The function ``add2virtualenv`` adds the specified directories to the Python path for the active virtualenv. The directory names passed as argument are added to a path file named ``virtualenv_path_extensions.pth`` inside the virtualenv's site-packages directory. If this file does not exist, it will be created first.
108+
The function ``add2virtualenv`` adds the specified directories to the Python path for the
109+
active virtualenv. The directory names passed as argument are added to a path file named
110+
``virtualenv_path_extensions.pth`` inside the virtualenv's site-packages directory. If this
111+
file does not exist, it will be created first.
107112

108113
==================================
109114
Quickly Navigating to a virtualenv
110115
==================================
111116

112-
The functions ``cdsitepackages`` and ``cdvirtualenv`` provide quick shortcuts to quickly ``cd`` into the ``site-packages`` directory of the currently-active virtualenv, and to the root of the currently-active virtualenv, respectively.
117+
The functions ``cdsitepackages`` and ``cdvirtualenv`` provide quick shortcuts to quickly
118+
``cd`` into the ``site-packages`` directory of the currently-active virtualenv, and to the
119+
root of the currently-active virtualenv, respectively.
113120

114121
==========
115122
References
116123
==========
117124

118-
For more details, refer to the column I wrote for the May 2008 issue of Python Magazine: `virtualenvwrapper | And Now For Something Completely Different <http://www.doughellmann.com/articles/CompletelyDifferent-2008-05-virtualenvwrapper/index.html>`_.
125+
For more details, refer to the column published in the May 2008 issue of Python Magazine:
126+
`virtualenvwrapper | And Now For Something Completely Different
127+
<http://www.doughellmann.com/articles/CompletelyDifferent-2008-05-virtualenvwrapper/index.html>`_.
119128

120129
=======
121130
Updates
@@ -125,6 +134,8 @@ Updates
125134
- Check return value of virtualenvwrapper_verify_workon_home everywhere, thanks to
126135
Jeff Forcier for pointing out the errors.
127136
- Fix instructions at top of README, pointed out by Matthew Scott.
137+
- Add cdvirtualenv and cdsitepackages, contributed by James Bennett.
138+
- Enhance test.sh.
128139

129140
1.11
130141
- Optimize virtualenvwrapper_show_workon_options.

pavement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
# What project are we building?
2424
PROJECT = 'virtualenvwrapper'
25-
VERSION = '1.11'
25+
VERSION = '1.12'
2626

2727
# Read the long description to give to setup
2828
README_FILE = 'README'

test.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,42 @@ echo "CREATING AND ACTIVATING"
2929
mkvirtualenv "env1"
3030
echo "Current environment: $VIRTUAL_ENV"
3131

32+
echo
33+
echo "NAVIGATION"
34+
echo -n "remember where we start "
35+
pushd `pwd`
36+
cdvirtualenv
37+
echo "cdvirtualenv: `pwd`"
38+
cdsitepackages
39+
echo "cdsitepackages: `pwd`"
40+
echo -n "back to where we started "
41+
popd
42+
3243
echo
3344
echo "CREATING AND SWITCHING"
3445
mkvirtualenv "env2"
3546
echo "Current environment: $VIRTUAL_ENV"
47+
echo -n "virtualenvwrapper_verify_active_environment: "
48+
virtualenvwrapper_verify_active_environment && echo "PASS" || echo "FAIL"
3649

3750
echo
3851
echo "POSTACTIVATE HOOK"
3952
echo "echo postactivate" > $WORKON_HOME/env1/bin/postactivate
4053
workon env1
54+
echo -n "virtualenvwrapper_verify_active_environment: "
55+
virtualenvwrapper_verify_active_environment && echo "PASS" || echo "FAIL"
4156

4257
echo
4358
echo "DEACTIVATING"
4459
deactivate
60+
echo "VIRTUAL_ENV: $VIRTUAL_ENV"
61+
echo "virtualenvwrapper_verify_active_environment: "
62+
virtualenvwrapper_verify_active_environment && echo "FAIL" || echo "PASS"
4563

4664
echo
4765
echo "LISTING ENVIRONMENTS"
4866
envs=`workon | tr '\n' ' '`
67+
echo "Found environments: $envs"
4968
if [ "$envs" = "env1 env2 " ]
5069
then
5170
echo "PASS"
@@ -62,6 +81,9 @@ rm -rf $WORKON_HOME
6281

6382
echo
6483
echo "MISSING WORKON_HOME"
84+
echo -n "workon: "
6585
workon && echo "Failed to detect missing dir" || echo "PASS"
86+
echo -n "mkvirtualenv: "
6687
mkvirtualenv foo && echo "Failed to detect missing dir" || echo "PASS"
88+
echo -n "rmvirtualenv: "
6789
rmvirtualenv foo && echo "Failed to detect missing dir" || echo "PASS"

virtualenvwrapper_bashrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ function add2virtualenv () {
224224
#
225225

226226
function cdsitepackages () {
227-
verify_active_environment || return 1
227+
virtualenvwrapper_verify_active_environment || return 1
228228
pyvers="`python -c 'import sys; print sys.version[:3]'`"
229229
site_packages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages"
230230
cd $site_packages
@@ -237,6 +237,6 @@ function cdsitepackages () {
237237
#
238238

239239
function cdvirtualenv () {
240-
verify_active_environment || return 1
240+
virtualenvwrapper_verify_active_environment || return 1
241241
cd $VIRTUAL_ENV
242242
}

0 commit comments

Comments
 (0)