]> granicus.if.org Git - python/commitdiff
fixed the move api in packaging.install, and closing the handle left by mkstemp(...
authorTarek Ziade <tarek@ziade.org>
Sat, 21 May 2011 13:12:10 +0000 (15:12 +0200)
committerTarek Ziade <tarek@ziade.org>
Sat, 21 May 2011 13:12:10 +0000 (15:12 +0200)
Lib/packaging/install.py
Lib/packaging/tests/test_install.py

index 3904727d450309901019b0b69c6b3def0d224c45..92657ea3d8ea5fb071fc041c38e2c5c15623a955 100644 (file)
@@ -47,10 +47,8 @@ def _move_files(files, destination):
         destination = tempfile.mkdtemp()
 
     for old in files:
-        # not using os.path.join() because basename() might not be
-        # unique in destination
-        new = "%s%s" % (destination, old)
-
+        filename = os.path.split(old)[-1]
+        new = os.path.join(destination, filename)
         # try to make the paths.
         try:
             os.makedirs(os.path.dirname(new))
index 7bdee943afc7d8023ee72a5f9312a1484a52752f..01c3dcf6b43f7af471438041af14e89f1e18e687 100644 (file)
@@ -43,16 +43,18 @@ class ToInstallDist:
         self.version = "fake"
         if files:
             for f in range(0, 3):
-                self._real_files.append(mkstemp())
+                fp, fn = mkstemp()
+                os.close(fp)
+                self._real_files.append(fn)
 
     def _unlink_installed_files(self):
         if self._files:
-            for f in self._real_files:
-                os.unlink(f[1])
+            for fn in self._real_files:
+                os.unlink(fn)
 
     def list_installed_files(self, **args):
         if self._files:
-            return [f[1] for f in self._real_files]
+            return self._real_files
 
     def get_install(self, **args):
         return self.list_installed_files()
@@ -231,8 +233,10 @@ class TestInstall(LoggingCatcher, TempdirManager, unittest.TestCase):
         output = [o for o in install._move_files(files, newpath)]
 
         # check that output return the list of old/new places
-        for f in files:
-            self.assertIn((f, '%s%s' % (newpath, f)), output)
+        for file_ in files:
+            name = os.path.split(file_)[-1]
+            newloc = os.path.join(newpath, name)
+            self.assertIn((file_, newloc), output)
 
         # remove the files
         for f in [o[1] for o in output]:  # o[1] is the new place