aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2012-04-07 13:26:44 -0400
committerJason R. Coombs <jaraco@jaraco.com>2012-04-07 13:26:44 -0400
commitbf87c16fce3253d13370f9aa5a99473e646e439a (patch)
treefe627eecf3fe77b7581f05a5ae11598ecbaf4632
parent1a9a961d96c1f9c11719356d6f375cdfc17e7e6d (diff)
downloadexternal_python_setuptools-bf87c16fce3253d13370f9aa5a99473e646e439a.tar.gz
external_python_setuptools-bf87c16fce3253d13370f9aa5a99473e646e439a.tar.bz2
external_python_setuptools-bf87c16fce3253d13370f9aa5a99473e646e439a.zip
Set the argv context so that easy_install.main invokes the command as if it had been run from the command-line
--HG-- branch : distribute extra : rebase_source : 4916aebae87b1d83dc27b494715c89dce1ce1e12
-rw-r--r--setuptools/tests/test_easy_install.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py
index 3f38d50f..bec03ab5 100644
--- a/setuptools/tests/test_easy_install.py
+++ b/setuptools/tests/test_easy_install.py
@@ -281,11 +281,11 @@ class TestSetupRequires(unittest.TestCase):
'--allow-hosts', p_index_loc,
'--exclude-scripts', '--install-dir', temp_install_dir,
dist_file]
- # attempt to install the dist. It should fail because
- # our fake server can't actually supply the dependency
- self.assertRaises(SystemExit,
- easy_install_pkg.main, ei_params)
- #self.assertTrue(os.listdir(temp_install_dir))
+ 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/')
@@ -333,3 +333,10 @@ def environment_context(**updates):
for key in updates:
del os.environ[key]
os.environ.update(old_env)
+
+@contextlib.contextmanager
+def argv_context(repl):
+ old_argv = sys.argv[:]
+ sys.argv[:] = repl
+ yield
+ sys.argv[:] = old_argv