Testing sanity checks (e.g. test_correct_pip_version) now pass on all target platforms.

This commit is contained in:
Dave Abrahams 2010-04-28 11:41:55 -04:00
parent e9bbd2a2a6
commit 55fc4610be
3 changed files with 29 additions and 22 deletions

View File

@ -186,3 +186,5 @@ class Path(_base):
def glob(self, pattern):
from glob import glob
return map(Path, glob(_base(self/pattern)))
curdir = Path(os.path.curdir)

View File

@ -1,5 +1,5 @@
from os.path import abspath, exists, join, dirname, curdir, pardir
from test_pip import here, reset_env, run_pip, pyversion, lib_py, mkdir
from test_pip import here, reset_env, run_pip, pyversion, mkdir
def test_correct_pip_version():
"""
@ -46,10 +46,11 @@ def test_install_from_pypi():
Test installing a package from PyPI.
"""
reset_env()
e = reset_env()
result = run_pip('install', '-vvv', 'INITools==0.2', expect_error=True)
assert (lib_py + 'site-packages/INITools-0.2-py%s.egg-info' % pyversion) in result.files_created, str(result)
assert (lib_py + 'site-packages/initools') in result.files_created, sorted(result.files_created.keys())
new_files = sorted(result.files_created.keys())
assert (e.site_packages / 'INITools-0.2-py%s.egg-info' % pyversion) in result.files_created, sorted(result.files_created.keys())
assert (e.site_packages / 'initools') in result.files_created, sorted(result.files_created.keys())
def test_editable_install():
"""
@ -67,12 +68,12 @@ def test_install_editable_from_svn():
Test checking out from svn.
"""
reset_env()
e = reset_env()
result = run_pip('install', '-e', 'svn+http://svn.colorstudy.com/INITools/trunk#egg=initools-dev', expect_error=True)
egg_link = result.files_created[lib_py + 'site-packages/INITools.egg-link']
egg_link = result.files_created[e.site_packages / 'INITools.egg-link']
# FIXME: I don't understand why there's a trailing . here:
assert egg_link.bytes.endswith('/test-scratch/src/initools\n.'), egg_link.bytes
assert (lib_py + 'site-packages/easy-install.pth') in result.files_updated
assert (e.site_packages / 'easy-install.pth') in result.files_updated
assert 'src/initools' in result.files_created
assert 'src/initools/.svn' in result.files_created
@ -146,18 +147,18 @@ def test_install_dev_version_from_pypi():
Test using package==dev.
"""
reset_env()
e = reset_env()
result = run_pip('install', 'INITools==dev', expect_error=True)
assert (lib_py + 'site-packages/initools') in result.files_created, str(result.stdout)
assert (e.site_packages / 'initools') in result.files_created, str(result.stdout)
def test_install_editable_from_git():
"""
Test cloning from Git.
"""
reset_env()
e = reset_env()
result = run_pip('install', '-e', 'git://github.com/jezdez/django-feedutil.git#egg=django-feedutil', expect_error=True)
egg_link = result.files_created[lib_py + 'site-packages/django-feedutil.egg-link']
egg_link = result.files_created[e.site_packages / 'django-feedutil.egg-link']
# FIXME: I don't understand why there's a trailing . here:
assert egg_link.bytes.endswith('.'), egg_link.bytes
#remove trailing "\n." and check that django-feedutil was installed
@ -171,9 +172,9 @@ def test_install_editable_from_hg():
Test cloning from Mercurial.
"""
reset_env()
e = reset_env()
result = run_pip('install', '-e', 'hg+http://bitbucket.org/ubernostrum/django-registration/#egg=django-registration', expect_error=True)
egg_link = result.files_created[lib_py + 'site-packages/django-registration.egg-link']
egg_link = result.files_created[e.site_packages / 'django-registration.egg-link']
# FIXME: I don't understand why there's a trailing . here:
assert egg_link.bytes.endswith('.'), egg_link.bytes
#remove trailing "\n." and check that django-registration was installed
@ -197,9 +198,9 @@ def test_install_editable_from_bazaar():
Test checking out from Bazaar.
"""
reset_env()
e = reset_env()
result = run_pip('install', '-e', 'bzr+http://bazaar.launchpad.net/%7Edjango-wikiapp/django-wikiapp/release-0.1/@174#egg=django-wikiapp', expect_error=True)
egg_link = result.files_created[lib_py + 'site-packages/django-wikiapp.egg-link']
egg_link = result.files_created[e.site_packages / 'django-wikiapp.egg-link']
# FIXME: I don't understand why there's a trailing . here:
assert egg_link.bytes.endswith('.'), egg_link.bytes
#remove trailing "\n." and check that django-wikiapp was installed

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
import os, sys, tempfile, shutil, glob, atexit
from path import Path
from path import *
pyversion = sys.version[:3]
@ -122,14 +122,16 @@ class TestPipEnvironment(TestFileEnvironment):
self.site_packages = Path(self.lib_dir[len(self.root_path):].lstrip(Path.sep)) / 'site-packages'
# put the test-scratch virtualenv's bin dir first on the PATH
self.environ['PATH'] = os.path.pathsep.join( (self.bin_dir, env.environ['PATH']) )
self.environ['PATH'] = os.path.pathsep.join( (self.bin_dir, self.environ['PATH']) )
# test that test-scratch virtualenv creation produced sensible venv python
result = self.run('python', '-c', 'import sys; print sys.executable')
pythonbin = result.stdout.strip()
if pythonbin != os.path.join(self.bin_dir, "python"):
raise RuntimeError("Python sys.executable (%r) isn't the "
"test-scratch venv python" % pythonbin)
if Path(pythonbin).noext != self.bin_dir/'python':
raise RuntimeError(
"Oops! 'python' in our test environment runs %r"
" rather than expected %r" % (pythonbin, self.bin_dir/'python'))
# make sure we have current setuptools to avoid svn incompatibilities
install_setuptools(self)
@ -148,8 +150,10 @@ class TestPipEnvironment(TestFileEnvironment):
shutil.rmtree(self.root_path, ignore_errors=True)
def run_pip(*args, **kw):
assert not 'run_from' in kw, '**** Use "cwd" instead of "run_from"!'
return env.run('pip', cwd=run_from, *args, **kw)
# assert not 'run_from' in kw, '**** Use "cwd" instead of "run_from"!'
cwd = kw.get('run_from', get_env().cwd)
kw.pop('run_from', None)
return env.run('pip', cwd=cwd, *args, **kw)
def write_file(filename, text, dest=None):
"""Write a file in the dest (default=env.scratch_path)