From 78ea429dac53a07cde782e04ea2dc2581ae5b74a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 2 Jun 2014 06:32:59 -0700 Subject: Have git ignore files created by tests When the tests are run, some packages are installed or created in the current directory. They should never be checked in, so add them to .gitignore. Change-Id: Ic7790ec85c9e2f0fc4bd06b492f75ea6c17ecda4 --HG-- extra : rebase_source : 7ad1502fd5d09d38f521a391e22af46cfce6ea4f --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..6167a533 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.tox +py-*.egg +pytest-*.egg -- cgit v1.2.3 From 6f98e16c52f7467d920bea4af3cbd262c6c5f5dc Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 2 Jun 2014 07:34:26 -0700 Subject: Add integration tests. Set up integration tests that install packages to temporary directories. Change-Id: Iec90838fec961228fca24c0decc088de55303350 --HG-- extra : rebase_source : f5219f8411db4b79694a74659e22b0c0b1c771ab --- setuptools/tests/test_integration.py | 87 ++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 setuptools/tests/test_integration.py 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') -- cgit v1.2.3 From 6168f740b5306903d601d97e30adc28ab64bb612 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 2 Jun 2014 07:44:54 -0700 Subject: update .gitignore from .hgignore Change-Id: I6789ef2eda75748597c9ae76f2a5389140a9daab --HG-- extra : rebase_source : 48bd79fb7ee229a89a3796df14aadbcca8ace016 --- .gitignore | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.gitignore b/.gitignore index 6167a533..7b00d3c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,18 @@ +*.pyc +*~ +*.swp +.coverage .tox +distribute.egg-info +setuptools.egg-info +build +dist +lib +bin +include +\.Python +*.swp +CHANGES (links).txt +.git* py-*.egg pytest-*.egg -- cgit v1.2.3 From be98378594c42de60ff36e2681ebcecd8dafcd4f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 2 Jun 2014 08:20:27 -0700 Subject: Activate more of the integration tests. Change-Id: Ic3cc25a02de71b94a08f0bf64e8d8b01b572a23b --HG-- extra : rebase_source : a49971d71570380f1ef51a88897d72328de337ed --- setuptools/tests/test_integration.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/setuptools/tests/test_integration.py b/setuptools/tests/test_integration.py index fdb8831e..372535ec 100644 --- a/setuptools/tests/test_integration.py +++ b/setuptools/tests/test_integration.py @@ -74,14 +74,14 @@ 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_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_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') +def test_python_novaclient(install_context): + _install_one('python-novaclient', install_context, + 'novaclient', 'base.py') -- cgit v1.2.3 From 7f5307b04dfcd19cc3d894a921bfa85160369d6d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 15 Jun 2014 08:46:38 -0400 Subject: Remove unused variable and import --- setuptools/tests/test_integration.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/setuptools/tests/test_integration.py b/setuptools/tests/test_integration.py index 372535ec..0565e926 100644 --- a/setuptools/tests/test_integration.py +++ b/setuptools/tests/test_integration.py @@ -9,7 +9,6 @@ import shutil import site import sys import tempfile -import unittest import pytest @@ -54,7 +53,6 @@ def install_context(request): 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 -- cgit v1.2.3 From def90a0a72012590fccd9a8bc0e247242f09b795 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 15 Jun 2014 08:47:16 -0400 Subject: Mark failing tests as xfail --- setuptools/tests/test_integration.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setuptools/tests/test_integration.py b/setuptools/tests/test_integration.py index 0565e926..3938ccc5 100644 --- a/setuptools/tests/test_integration.py +++ b/setuptools/tests/test_integration.py @@ -72,14 +72,17 @@ 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') -- cgit v1.2.3