Jason R. Coombs avatar Jason R. Coombs committed 94e2308

Added another context to reset the _setup_stop_context

Comments (0)

Files changed (1)

setuptools/tests/test_easy_install.py

 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
                         '--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/')
 
     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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.