Index: Lib/distutils/tests/test_file_util.py =================================================================== --- Lib/distutils/tests/test_file_util.py (revision 69418) +++ Lib/distutils/tests/test_file_util.py (working copy) @@ -21,6 +21,7 @@ self.source = os.path.join(os.path.dirname(__file__), 'f1') self.target = os.path.join(os.path.dirname(__file__), 'f2') self.target_dir = os.path.join(os.path.dirname(__file__), 'd1') + self.file_in_dir = os.path.join(self.target_dir, 'f1') def tearDown(self): log.info = self.old_log @@ -58,7 +59,14 @@ wanted = ['moving %s -> %s' % (self.source, self.target_dir)] self.assertEquals(self._logs, wanted) + # back to original state + move_file(self.file_in_dir, self.source, verbose=0) + # check whether dry_run=1 returns the same path/filename + dry = move_file(self.source, self.target_dir, verbose=1, dry_run=1) + real = move_file(self.source, self.target_dir, verbose=1, dry_run=0) + self.assertEquals(dry, real) + def test_suite(): return unittest.makeSuite(FileUtilTestCase) Index: Lib/distutils/file_util.py =================================================================== --- Lib/distutils/file_util.py (revision 69418) +++ Lib/distutils/file_util.py (working copy) @@ -197,9 +197,6 @@ if verbose >= 1: log.info("moving %s -> %s", src, dst) - if dry_run: - return dst - if not isfile(src): raise DistutilsFileError, \ "can't move '%s': not a regular file" % src @@ -216,6 +213,9 @@ "can't move '%s': destination '%s' not a valid path" % \ (src, dst) + if dry_run: + return dst + copy_it = 0 try: os.rename(src, dst)