Mercurial > repos > bcclaywell > argo_navis
comparison venv/lib/python2.7/site-packages/setuptools/tests/test_integration.py @ 0:d67268158946 draft
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
author | bcclaywell |
---|---|
date | Mon, 12 Oct 2015 17:43:33 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d67268158946 |
---|---|
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 from setuptools.compat import urlopen | |
16 | |
17 | |
18 def setup_module(module): | |
19 packages = 'stevedore', 'virtualenvwrapper', 'pbr', 'novaclient' | |
20 for pkg in packages: | |
21 try: | |
22 __import__(pkg) | |
23 tmpl = "Integration tests cannot run when {pkg} is installed" | |
24 pytest.skip(tmpl.format(**locals())) | |
25 except ImportError: | |
26 pass | |
27 | |
28 try: | |
29 urlopen('https://pypi.python.org/pypi') | |
30 except Exception as exc: | |
31 pytest.skip(reason=str(exc)) | |
32 | |
33 | |
34 @pytest.fixture | |
35 def install_context(request, tmpdir, monkeypatch): | |
36 """Fixture to set up temporary installation directory. | |
37 """ | |
38 # Save old values so we can restore them. | |
39 new_cwd = tmpdir.mkdir('cwd') | |
40 user_base = tmpdir.mkdir('user_base') | |
41 user_site = tmpdir.mkdir('user_site') | |
42 install_dir = tmpdir.mkdir('install_dir') | |
43 | |
44 def fin(): | |
45 # undo the monkeypatch, particularly needed under | |
46 # windows because of kept handle on cwd | |
47 monkeypatch.undo() | |
48 new_cwd.remove() | |
49 user_base.remove() | |
50 user_site.remove() | |
51 install_dir.remove() | |
52 request.addfinalizer(fin) | |
53 | |
54 # Change the environment and site settings to control where the | |
55 # files are installed and ensure we do not overwrite anything. | |
56 monkeypatch.chdir(new_cwd) | |
57 monkeypatch.setattr(easy_install_pkg, '__file__', user_site.strpath) | |
58 monkeypatch.setattr('site.USER_BASE', user_base.strpath) | |
59 monkeypatch.setattr('site.USER_SITE', user_site.strpath) | |
60 monkeypatch.setattr('sys.path', sys.path + [install_dir.strpath]) | |
61 monkeypatch.setenv('PYTHONPATH', os.path.pathsep.join(sys.path)) | |
62 | |
63 # Set up the command for performing the installation. | |
64 dist = Distribution() | |
65 cmd = easy_install(dist) | |
66 cmd.install_dir = install_dir.strpath | |
67 return cmd | |
68 | |
69 | |
70 def _install_one(requirement, cmd, pkgname, modulename): | |
71 cmd.args = [requirement] | |
72 cmd.ensure_finalized() | |
73 cmd.run() | |
74 target = cmd.install_dir | |
75 dest_path = glob.glob(os.path.join(target, pkgname + '*.egg')) | |
76 assert dest_path | |
77 assert os.path.exists(os.path.join(dest_path[0], pkgname, modulename)) | |
78 | |
79 | |
80 def test_stevedore(install_context): | |
81 _install_one('stevedore', install_context, | |
82 'stevedore', 'extension.py') | |
83 | |
84 | |
85 @pytest.mark.xfail | |
86 def test_virtualenvwrapper(install_context): | |
87 _install_one('virtualenvwrapper', install_context, | |
88 'virtualenvwrapper', 'hook_loader.py') | |
89 | |
90 | |
91 def test_pbr(install_context): | |
92 _install_one('pbr', install_context, | |
93 'pbr', 'core.py') | |
94 | |
95 | |
96 @pytest.mark.xfail | |
97 def test_python_novaclient(install_context): | |
98 _install_one('python-novaclient', install_context, | |
99 'novaclient', 'base.py') |