Commits

Doug Hellmann committed 27085d7

fix #32 by removing use of 'with' ; add tests for python 2.6 and 2.5

Comments (0)

Files changed (10)

 # Get the version of the app.  This is used in the doc build.
 export VERSION=$(shell python setup.py --version)
 
+# The main version of Python supported.
+PRIMARY_PYTHON_VERSION=2.6
+
+# The test-quick pattern changes the definition of
+# this variable to only run against a single version of python.
+ifeq ($(SUPPORTED_PYTHON_VERSIONS),)
+SUPPORTED_PYTHON_VERSIONS=2.5 2.6
+endif
+
 # Default target is to show help
 help:
 	@echo "sdist          - Source distribution"
 TEST_SCRIPTS=$(wildcard tests/test*.sh)
 
 .PHONY: develop test test-bash test-sh test-zsh test-loop test-install
-test: develop test-bash test-sh test-zsh test-install
+test: test-bash test-sh test-zsh test-install
 
 develop:
 	python setup.py develop
 test-zsh:
 	TEST_SHELL="zsh -o shwordsplit" $(MAKE) test-loop
 
+# For each supported version of Python,
+# - Create a new virtualenv in a temporary directory.
+# - Install virtualenvwrapper into the new virtualenv
+# - Run each test script in tests
 test-loop:
-	@for test_script in $(wildcard tests/test*.sh) ; do \
-	 	echo '********************************************************************************' ; \
-		echo "Running $$test_script with $(TEST_SHELL)" ; \
-		SHUNIT_PARENT=$$test_script $(TEST_SHELL) $$test_script || exit 1 ; \
-		echo ; \
+	for py_ver in $(SUPPORTED_PYTHON_VERSIONS) ; do \
+		(cd $$TMPDIR/ && rm -rf virtualenvwrapper-test-env \
+			&& virtualenv -p /Library/Frameworks/Python.framework/Versions/$$py_ver/bin/python$$py_ver --no-site-packages virtualenvwrapper-test-env) \
+			|| exit 1 ; \
+		$$TMPDIR/virtualenvwrapper-test-env/bin/python setup.py install || exit 1 ; \
+		for test_script in $(wildcard tests/test*.sh) ; do \
+	 		echo '********************************************************************************' ; \
+			echo "Running $$test_script with $(TEST_SHELL) under Python $$py_ver" ; \
+			VIRTUALENVWRAPPER_PYTHON=$$TMPDIR/virtualenvwrapper-test-env/bin/python SHUNIT_PARENT=$$test_script $(TEST_SHELL) $$test_script || exit 1 ; \
+			echo ; \
+		done \
 	done
 
+test-quick:
+	SUPPORTED_PYTHON_VERSIONS=$(PRIMARY_PYTHON_VERSION) $(MAKE) test-bash
+
 test-install:
 	bash ./tests/manual_test_install.sh `pwd`/dist "$(VERSION)"
 #set -x
 
 test_dir=$(dirname $0)
-source "$test_dir/../virtualenvwrapper.sh"
 
 export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
 
 oneTimeSetUp() {
     rm -rf "$WORKON_HOME"
     mkdir -p "$WORKON_HOME"
+    source "$test_dir/../virtualenvwrapper.sh"
+    echo $PYTHONPATH
 }
 
 oneTimeTearDown() {

tests/test_add2virtualenv.sh

 #set -x
 
 test_dir=$(dirname $0)
-source "$test_dir/../virtualenvwrapper.sh"
 
 export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
 
 oneTimeSetUp() {
     rm -rf "$WORKON_HOME"
     mkdir -p "$WORKON_HOME"
+    source "$test_dir/../virtualenvwrapper.sh"
 }
 
 oneTimeTearDown() {
 #set -x
 
 test_dir=$(dirname $0)
-source "$test_dir/../virtualenvwrapper.sh"
 
 export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
 
 oneTimeSetUp() {
     rm -rf "$WORKON_HOME"
     mkdir -p "$WORKON_HOME"
+    source "$test_dir/../virtualenvwrapper.sh"
 }
 
 oneTimeTearDown() {
 #set -x
 
 test_dir=$(dirname $0)
-source "$test_dir/../virtualenvwrapper.sh"
 
 export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
 
 setUp () {
     rm -rf "$WORKON_HOME"
     mkdir -p "$WORKON_HOME"
+    source "$test_dir/../virtualenvwrapper.sh"
     echo
     rm -f "$test_dir/catch_output"
 }
 #set -x
 
 test_dir=$(dirname $0)
-source "$test_dir/../virtualenvwrapper.sh"
 
 export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
 
 oneTimeSetUp() {
     rm -rf "$WORKON_HOME"
     mkdir -p "$WORKON_HOME"
+    source "$test_dir/../virtualenvwrapper.sh"
 }
 
 oneTimeTearDown() {

tests/test_rmvirtualenv.sh

 #set -x
 
 test_dir=$(dirname $0)
-source "$test_dir/../virtualenvwrapper.sh"
 
 export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME"
 
 oneTimeSetUp() {
     rm -rf "$WORKON_HOME"
     mkdir -p "$WORKON_HOME"
+    source "$test_dir/../virtualenvwrapper.sh"
 }
 
 oneTimeTearDown() {

tests/test_tmpdir.sh

 #set -x
 
 test_dir=$(dirname $0)
-#source "$test_dir/../virtualenvwrapper.sh"
 
 export SCRATCH_DIR="${TMPDIR:-/tmp}/test_scratch_dir"
 

virtualenvwrapper.sh

 fi
 
 # Locate the global Python where virtualenvwrapper is installed.
-VIRTUALENVWRAPPER_PYTHON="$(which python)"
+if [ "$VIRTUALENVWRAPPER_PYTHON" = "" ]
+then
+    VIRTUALENVWRAPPER_PYTHON="$(which python)"
+fi
 
 # Normalize the directory name in case it includes 
 # relative path components.

virtualenvwrapper/user_scripts.py

     filename = os.path.expanduser(os.path.expandvars(filename))
     if not os.path.exists(filename):
         log.info('Creating %s', filename)
-        with open(filename, 'wt') as f:
+        f = open(filename, 'wt')
+        try:
             f.write("""#!%(shell)s
 # %(comment)s
 
 """ % {'comment':comment, 'shell':os.environ.get('SHELL', '/bin/sh')})
+        finally:
+            f.close()
         os.chmod(filename, PERMISSIONS)
     return
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.