OLD | NEW |
(Empty) | |
| 1 """Run some integration tests. |
| 2 |
| 3 Try to install a few packages. |
| 4 """ |
| 5 |
| 6 import glob |
| 7 import os |
| 8 import sys |
| 9 |
| 10 import pytest |
| 11 |
| 12 from setuptools.command.easy_install import easy_install |
| 13 from setuptools.command import easy_install as easy_install_pkg |
| 14 from setuptools.dist import Distribution |
| 15 |
| 16 |
| 17 @pytest.fixture |
| 18 def install_context(request, tmpdir, monkeypatch): |
| 19 """Fixture to set up temporary installation directory. |
| 20 """ |
| 21 # Save old values so we can restore them. |
| 22 new_cwd = tmpdir.mkdir('cwd') |
| 23 user_base = tmpdir.mkdir('user_base') |
| 24 user_site = tmpdir.mkdir('user_site') |
| 25 install_dir = tmpdir.mkdir('install_dir') |
| 26 |
| 27 def fin(): |
| 28 # undo the monkeypatch, particularly needed under |
| 29 # windows because of kept handle on cwd |
| 30 monkeypatch.undo() |
| 31 new_cwd.remove() |
| 32 user_base.remove() |
| 33 user_site.remove() |
| 34 install_dir.remove() |
| 35 request.addfinalizer(fin) |
| 36 |
| 37 # Change the environment and site settings to control where the |
| 38 # files are installed and ensure we do not overwrite anything. |
| 39 monkeypatch.chdir(new_cwd) |
| 40 monkeypatch.setattr(easy_install_pkg, '__file__', user_site.strpath) |
| 41 monkeypatch.setattr('site.USER_BASE', user_base.strpath) |
| 42 monkeypatch.setattr('site.USER_SITE', user_site.strpath) |
| 43 monkeypatch.setattr('sys.path', sys.path + [install_dir.strpath]) |
| 44 monkeypatch.setenv('PYTHONPATH', os.path.pathsep.join(sys.path)) |
| 45 |
| 46 # Set up the command for performing the installation. |
| 47 dist = Distribution() |
| 48 cmd = easy_install(dist) |
| 49 cmd.install_dir = install_dir.strpath |
| 50 return cmd |
| 51 |
| 52 |
| 53 def _install_one(requirement, cmd, pkgname, modulename): |
| 54 cmd.args = [requirement] |
| 55 cmd.ensure_finalized() |
| 56 cmd.run() |
| 57 target = cmd.install_dir |
| 58 dest_path = glob.glob(os.path.join(target, pkgname + '*.egg')) |
| 59 assert dest_path |
| 60 assert os.path.exists(os.path.join(dest_path[0], pkgname, modulename)) |
| 61 |
| 62 |
| 63 def test_stevedore(install_context): |
| 64 _install_one('stevedore', install_context, |
| 65 'stevedore', 'extension.py') |
| 66 |
| 67 |
| 68 @pytest.mark.xfail |
| 69 def test_virtualenvwrapper(install_context): |
| 70 _install_one('virtualenvwrapper', install_context, |
| 71 'virtualenvwrapper', 'hook_loader.py') |
| 72 |
| 73 |
| 74 @pytest.mark.xfail |
| 75 def test_pbr(install_context): |
| 76 _install_one('pbr', install_context, |
| 77 'pbr', 'core.py') |
| 78 |
| 79 |
| 80 @pytest.mark.xfail |
| 81 def test_python_novaclient(install_context): |
| 82 _install_one('python-novaclient', install_context, |
| 83 'novaclient', 'base.py') |
OLD | NEW |