diff options
Diffstat (limited to 'setuptools/tests')
-rw-r--r-- | setuptools/tests/test_develop.py | 6 | ||||
-rw-r--r-- | setuptools/tests/test_find_packages.py | 16 | ||||
-rw-r--r-- | setuptools/tests/test_integration.py | 80 |
3 files changed, 97 insertions, 5 deletions
diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 18f35c0f..66d182eb 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -9,8 +9,6 @@ import unittest from distutils.errors import DistutilsError from setuptools.command.develop import develop -from setuptools.command import easy_install as easy_install_pkg -from setuptools.compat import StringIO from setuptools.dist import Distribution SETUP_PY = """\ @@ -114,11 +112,11 @@ class TestDevelopTest(unittest.TestCase): os.chdir(self.dir) try: try: - dist = Distribution({'setup_requires': ['I_DONT_EXIST']}) + Distribution({'setup_requires': ['I_DONT_EXIST']}) except DistutilsError: e = sys.exc_info()[1] error = str(e) - if error == wanted: + if error == wanted: pass finally: os.chdir(old_dir) diff --git a/setuptools/tests/test_find_packages.py b/setuptools/tests/test_find_packages.py index 92f7aff7..fe390728 100644 --- a/setuptools/tests/test_find_packages.py +++ b/setuptools/tests/test_find_packages.py @@ -12,12 +12,26 @@ from setuptools.tests.py26compat import skipIf find_420_packages = setuptools.PEP420PackageFinder.find +# modeled after CPython's test.support.can_symlink +def can_symlink(): + TESTFN = tempfile.mktemp() + symlink_path = TESTFN + "can_symlink" + try: + os.symlink(TESTFN, symlink_path) + can = True + except (OSError, NotImplementedError, AttributeError): + can = False + else: + os.remove(symlink_path) + globals().update(can_symlink=lambda: can) + return can + def has_symlink(): bad_symlink = ( # Windows symlink directory detection is broken on Python 3.2 platform.system() == 'Windows' and sys.version_info[:2] == (3,2) ) - return hasattr(os, 'symlink') and not bad_symlink + return can_symlink() and not bad_symlink class TestFindPackages(unittest.TestCase): diff --git a/setuptools/tests/test_integration.py b/setuptools/tests/test_integration.py new file mode 100644 index 00000000..7144aa6c --- /dev/null +++ b/setuptools/tests/test_integration.py @@ -0,0 +1,80 @@ +"""Run some integration tests. + +Try to install a few packages. +""" + +import glob +import os +import sys + +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, tmpdir, monkeypatch): + """Fixture to set up temporary installation directory. + """ + # Save old values so we can restore them. + new_cwd = tmpdir.mkdir('cwd') + user_base = tmpdir.mkdir('user_base') + user_site = tmpdir.mkdir('user_site') + install_dir = tmpdir.mkdir('install_dir') + + def fin(): + new_cwd.remove() + user_base.remove() + user_site.remove() + install_dir.remove() + request.addfinalizer(fin) + + # Change the environment and site settings to control where the + # files are installed and ensure we do not overwrite anything. + monkeypatch.chdir(new_cwd) + monkeypatch.setattr(easy_install_pkg, '__file__', user_site.strpath) + monkeypatch.setattr('site.USER_BASE', user_base.strpath) + monkeypatch.setattr('site.USER_SITE', user_site.strpath) + monkeypatch.setattr('sys.path', sys.path + [install_dir.strpath]) + monkeypatch.setenv('PYTHONPATH', os.path.pathsep.join(sys.path)) + + # Set up the command for performing the installation. + dist = Distribution() + cmd = easy_install(dist) + cmd.install_dir = install_dir.strpath + 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') + + +@pytest.mark.xfail +def test_virtualenvwrapper(install_context): + _install_one('virtualenvwrapper', install_context, + 'virtualenvwrapper', 'hook_loader.py') + + +@pytest.mark.xfail +def test_pbr(install_context): + _install_one('pbr', install_context, + 'pbr', 'core.py') + + +@pytest.mark.xfail +def test_python_novaclient(install_context): + _install_one('python-novaclient', install_context, + 'novaclient', 'base.py') |