Tarek Ziadé avatar Tarek Ziadé committed aa5216d

added a test for #143 now that I understand it. fixes #143

Comments (0)

Files changed (1)

setuptools/tests/test_easy_install.py

         cmd.args = ['py']
         cmd.initialize_options()
         self.assertFalse(cmd.user, 'NOT user should be implied')
+
+    def test_local_index(self):
+        # make sure the local index is used
+        # when easy_install looks for installed
+        # packages
+        new_location = tempfile.mkdtemp()
+        target = tempfile.mkdtemp()
+        egg_file = os.path.join(new_location, 'foo-1.0.egg-info')
+        f = open(egg_file, 'w')
+        try:
+            f.write('Name: foo\n')
+        except:
+            f.close()
+
+        sys.path.append(target)
+        old_ppath = os.environ.get('PYTHONPATH')
+        os.environ['PYTHONPATH'] = ':'.join(sys.path)
+        try:
+            dist = Distribution()
+            dist.script_name = 'setup.py'
+            cmd = easy_install(dist)
+            cmd.install_dir = target
+            cmd.args = ['foo']
+            cmd.ensure_finalized()
+            cmd.local_index.scan([new_location])
+            res = cmd.easy_install('foo')
+            self.assertEquals(res.location, new_location)
+        finally:
+            sys.path.remove(target)
+            shutil.rmtree(new_location)
+            shutil.rmtree(target)
+            if old_ppath is not None:
+                os.environ['PYTHONPATH'] = old_ppath
+            else:
+                del os.environ['PYTHONPATH']
+
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.