Commits

Jason R. Coombs  committed 101e09a

Set the argv context so that easy_install.main invokes the command as if it had been run from the command-line

  • Participants
  • Parent commits 60aeb2c

Comments (0)

Files changed (1)

File setuptools/tests/test_easy_install.py

                         '--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/')
 
         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