diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2012-04-07 13:43:29 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2012-04-07 13:43:29 -0400 |
commit | ed8d0afca6d513359e16b9e9acf409dd430b50de (patch) | |
tree | 4b7f5ab088009fffc68f4abba21e350c4770cd83 /setuptools/tests/test_easy_install.py | |
parent | bf87c16fce3253d13370f9aa5a99473e646e439a (diff) | |
download | external_python_setuptools-ed8d0afca6d513359e16b9e9acf409dd430b50de.tar.gz external_python_setuptools-ed8d0afca6d513359e16b9e9acf409dd430b50de.tar.bz2 external_python_setuptools-ed8d0afca6d513359e16b9e9acf409dd430b50de.zip |
Added another context to reset the _setup_stop_context
--HG--
branch : distribute
extra : rebase_source : b31f921755cea6d2559c9f24f42b737aa80198e7
Diffstat (limited to 'setuptools/tests/test_easy_install.py')
-rw-r--r-- | setuptools/tests/test_easy_install.py | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index bec03ab5..c5fb4d9d 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -11,6 +11,7 @@ import textwrap import tarfile import urlparse import StringIO +import distutils.core from setuptools.command.easy_install import easy_install, get_script_args, main from setuptools.command.easy_install import PthDistributions @@ -281,11 +282,12 @@ class TestSetupRequires(unittest.TestCase): '--allow-hosts', p_index_loc, '--exclude-scripts', '--install-dir', temp_install_dir, dist_file] - with argv_context(['easy_install']): - # attempt to install the dist. It should fail because - # it doesn't exist. - self.assertRaises(SystemExit, - easy_install_pkg.main, ei_params) + with reset_setup_stop_context(): + with argv_context(['easy_install']): + # attempt to install the dist. It should fail because + # it doesn't exist. + self.assertRaises(SystemExit, + easy_install_pkg.main, ei_params) self.assertEqual(len(p_index.requests), 2) self.assertEqual(p_index.requests[0].path, '/does-not-exist/') @@ -340,3 +342,16 @@ def argv_context(repl): sys.argv[:] = repl yield sys.argv[:] = old_argv + +@contextlib.contextmanager +def reset_setup_stop_context(): + """ + When the distribute tests are run using setup.py test, and then + one wants to invoke another setup() command (such as easy_install) + within those tests, it's necessary to reset the global variable + in distutils.core so that the setup() command will run naturally. + """ + setup_stop_after = distutils.core._setup_stop_after + distutils.core._setup_stop_after = None + yield + distutils.core._setup_stop_after = setup_stop_after |