changeset 65:83327bc715be

make the virtualenv convenience method return more stuff
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 01 Mar 2012 18:31:52 -0800
parents bb8d993376aa
children a2ba66be2e31
files tests/test.py tests/test_ttw.txt tests/test_wsgi.txt
diffstat 3 files changed, 31 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test.py	Thu Mar 01 18:15:34 2012 -0800
+++ b/tests/test.py	Thu Mar 01 18:31:52 2012 -0800
@@ -21,11 +21,15 @@
 def create_virtualenv(path):
     """create a virtualenv and return the path to the python interpreter therein"""
     virtualenv.create_environment(path)
-    for python in (('bin', 'python'), ('Scripts', 'python.exe')):
-        python = os.path.join(path, *python)
-        if os.path.exists(python):
-            return python
-    raise Exception("Python binary not found in %s" % path)
+    for scripts, ext in (('bin', ''), ('Scripts', '.exe')):
+        scripts = os.path.join(path, scripts)
+        if os.path.exists(scripts):
+            break
+    else:
+        raise Exception("bin/Scripts not found in %s" % path)
+    binaries = ['python', 'easy_install', 'pip']
+    binaries = dict([(i, i + ext) for i in binaries])
+    return type('virtualenv', (), binaries)
 
 def run_tests(raise_on_error=False, report_first=False):
 
--- a/tests/test_ttw.txt	Thu Mar 01 18:15:34 2012 -0800
+++ b/tests/test_ttw.txt	Thu Mar 01 18:31:52 2012 -0800
@@ -5,6 +5,7 @@
 
 The obligatory imports::
 
+    >>> import os
     >>> import urllib2
     >>> from simpypi.factory import factory
 
@@ -33,6 +34,26 @@
     >>> 'Simple Index' in contents
     True
 
+
+There should be no files to start out with::
+
+    >>> os.listdir(directory)
+    []
+
+Upload a file::
+
+    >>> path = os.path.join(here, 'HelloWorld-0.0.tar.gz')
+    >>> upload = MultiPartForm()
+    >>> upload.add_file('package', path)
+    >>> response = upload.post(url)
+
+Let's see if its in the right place::
+
+    >>> os.listdir(directory)
+    ['HelloWorld']
+    >>> os.listdir(os.path.join(directory, 'HelloWorld'))
+    ['HelloWorld-0.0.tar.gz']
+
 Shut down the server::
 
     >>> server.stop()
--- a/tests/test_wsgi.txt	Thu Mar 01 18:15:34 2012 -0800
+++ b/tests/test_wsgi.txt	Thu Mar 01 18:31:52 2012 -0800
@@ -69,7 +69,7 @@
 
 Install the package and inspect the installation::
 
-    >>> python = create_virtualenv(tmpdir)
+    >>> python = create_virtualenv(tmpdir).python
 
 You should not be able to import ``helloworld`` yet::