Mercurial > hg > simpypi
diff tests/test.py @ 55:143adebe4caa
install package in a virtualenv and make sure importing is sane
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 01 Mar 2012 15:28:34 -0800 |
parents | 486a4640fc31 |
children | 2e60fb704454 |
line wrap: on
line diff
--- a/tests/test.py Thu Mar 01 15:04:27 2012 -0800 +++ b/tests/test.py Thu Mar 01 15:28:34 2012 -0800 @@ -9,8 +9,18 @@ import shutil import sys import tempfile +import virtualenv from optparse import OptionParser +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) + def run_tests(raise_on_error=False, report_first=False): # add results here @@ -18,7 +28,7 @@ # doctest arguments directory = os.path.dirname(os.path.abspath(__file__)) - extraglobs = {'here': directory} + extraglobs = {'here': directory, 'create_virtualenv': create_virtualenv} doctest_args = dict(extraglobs=extraglobs, raise_on_error=raise_on_error) if report_first: doctest_args['optionflags'] = doctest.REPORT_ONLY_FIRST_FAILURE