diff options
author | Doug Hellmann <doug.hellmann@dreamhost.com> | 2014-06-02 07:34:26 -0700 |
---|---|---|
committer | Doug Hellmann <doug.hellmann@dreamhost.com> | 2014-06-02 07:34:26 -0700 |
commit | 6f98e16c52f7467d920bea4af3cbd262c6c5f5dc (patch) | |
tree | d49c1caa8c68dfc81adec747fefc8c7cbc1c754c /setuptools/tests | |
parent | 78ea429dac53a07cde782e04ea2dc2581ae5b74a (diff) | |
download | external_python_setuptools-6f98e16c52f7467d920bea4af3cbd262c6c5f5dc.tar.gz external_python_setuptools-6f98e16c52f7467d920bea4af3cbd262c6c5f5dc.tar.bz2 external_python_setuptools-6f98e16c52f7467d920bea4af3cbd262c6c5f5dc.zip |
Add integration tests.
Set up integration tests that install packages to temporary
directories.
Change-Id: Iec90838fec961228fca24c0decc088de55303350
--HG--
extra : rebase_source : f5219f8411db4b79694a74659e22b0c0b1c771ab
Diffstat (limited to 'setuptools/tests')
-rw-r--r-- | setuptools/tests/test_integration.py | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/setuptools/tests/test_integration.py b/setuptools/tests/test_integration.py new file mode 100644 index 00000000..fdb8831e --- /dev/null +++ b/setuptools/tests/test_integration.py @@ -0,0 +1,87 @@ +"""Run some integration tests. + +Try to install a few packages. +""" + +import glob +import os +import shutil +import site +import sys +import tempfile +import unittest + +import pytest + +from setuptools.command.easy_install import easy_install +from setuptools.command import easy_install as easy_install_pkg +from setuptools.dist import Distribution + + +@pytest.fixture +def install_context(request): + """Fixture to set up temporary installation directory. + """ + # Save old values so we can restore them. + new_cwd = tempfile.mkdtemp() + old_cwd = os.getcwd() + old_enable_site = site.ENABLE_USER_SITE + old_file = easy_install_pkg.__file__ + old_base = site.USER_BASE + old_site = site.USER_SITE + old_ppath = os.environ.get('PYTHONPATH') + + def fin(): + os.chdir(old_cwd) + shutil.rmtree(new_cwd) + shutil.rmtree(site.USER_BASE) + shutil.rmtree(site.USER_SITE) + site.USER_BASE = old_base + site.USER_SITE = old_site + site.ENABLE_USER_SITE = old_enable_site + easy_install_pkg.__file__ = old_file + os.environ['PYTHONPATH'] = old_ppath or '' + request.addfinalizer(fin) + + # Change the environment and site settings to control where the + # files are installed and ensure we do not overwrite anything. + site.USER_BASE = tempfile.mkdtemp() + site.USER_SITE = tempfile.mkdtemp() + easy_install_pkg.__file__ = site.USER_SITE + os.chdir(new_cwd) + install_dir = tempfile.mkdtemp() + sys.path.append(install_dir) + os.environ['PYTHONPATH'] = os.path.pathsep.join(sys.path) + + # Set up the command for performing the installation. + values = {} + dist = Distribution() + cmd = easy_install(dist) + cmd.install_dir = install_dir + return cmd + + +def _install_one(requirement, cmd, pkgname, modulename): + cmd.args = [requirement] + cmd.ensure_finalized() + cmd.run() + target = cmd.install_dir + dest_path = glob.glob(os.path.join(target, pkgname + '*.egg')) + assert dest_path + assert os.path.exists(os.path.join(dest_path[0], pkgname, modulename)) + +def test_stevedore(install_context): + _install_one('stevedore', install_context, + 'stevedore', 'extension.py') + +# def test_virtualenvwrapper(install_context): +# _install_one('virtualenvwrapper', install_context, +# 'virtualenvwrapper', 'hook_loader.py') + +# def test_pbr(install_context): +# _install_one('pbr', install_context, +# 'pbr', 'core.py') + +# def test_python_novaclient(install_context): +# _install_one('python-novaclient', install_context, +# 'novaclient', 'base.py') |