Rev 4956: Use os.rename() and fix some typos. in file:///home/vila/src/bzr/reviews/script-test-mv/

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Jan 13 17:21:29 GMT 2010


At file:///home/vila/src/bzr/reviews/script-test-mv/

------------------------------------------------------------
revno: 4956
revision-id: v.ladeuil+lp at free.fr-20100113172129-ih6sn8ho6b6pwuab
parent: nmb at wartburg.edu-20100113161945-k6fj0aqdnlk7usi4
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: script-test-mv
timestamp: Wed 2010-01-13 18:21:29 +0100
message:
  Use os.rename() and fix some typos.
  
  * bzrlib/tests/test_script.py:
  (TestMv.test_move_unknown_file): Check the error case.
  
  * bzrlib/tests/script.py:
  (ScriptRunner.do_mv): Us os.rename instead of shutil.move. It's
  less powerful but reflects more closely the expected limitations
  in the future transport-based implementation.
  
  * NEWS: 
  Always sorted in alphabetical order.
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2010-01-13 16:19:45 +0000
+++ b/NEWS	2010-01-13 17:21:29 +0000
@@ -172,14 +172,14 @@
   testtools less than 0.9.2 will cause bzr to error while loading the test
   suite. (Robert Collins)
 
+* Shell-like tests now support the command "mv" for moving files.  The
+  syntax for ``mv file1 file2``, ``mv dir1 dir2`` and ``mv file dir`` is
+  supported.  (Neil Martinsen-Burrell)
+
 * The test progress bar no longer distinguishes tests that 'errored' from
   tests that 'failed' - they're all just failures.
   (Martin Pool)
 
-* Shell-like tests no support the command "mv" for moving files.  The
-  syntax for ``mv file1 file2``, ``mv dir1 dir2`` and ``mv file dir`` is
-  supported.  (Neil Martinsen-Burrell)
-
 bzr 2.0.4 (not released yet)
 ############################
 

=== modified file 'bzrlib/tests/script.py'
--- a/bzrlib/tests/script.py	2010-01-13 02:45:07 +0000
+++ b/bzrlib/tests/script.py	2010-01-13 17:21:29 +0000
@@ -24,7 +24,6 @@
 import glob
 import os
 import shlex
-import shutil
 from cStringIO import StringIO
 
 from bzrlib import (
@@ -405,17 +404,20 @@
 
     def do_mv(self, test_case, input, args):
         err = None
-        def error(msg, path1, path2):
-            return "mv: cannot move %s to %s: %s\n" % (path1, path2, msg)
+        def error(msg, src, dst):
+            return "mv: cannot move %s to %s: %s\n" % (src, dst, msg)
 
         if not args or len(args) != 2:
             raise SyntaxError("Usage: mv path1 path2")
-        path1, path2 = args
+        src, dst = args
         try:
-            shutil.move(path1, path2)
+            real_dst = dst
+            if os.path.isdir(dst):
+                real_dst = os.path.join(dst, os.path.basename(src))
+            os.rename(src, real_dst)
         except OSError, e:
             if e.errno == errno.ENOENT:
-                err = error('No such file or directory', path1)
+                err = error('No such file or directory', src, dst)
             else:
                 raise
         if err:

=== modified file 'bzrlib/tests/test_script.py'
--- a/bzrlib/tests/test_script.py	2010-01-13 16:19:45 +0000
+++ b/bzrlib/tests/test_script.py	2010-01-13 17:21:29 +0000
@@ -423,6 +423,10 @@
         self.failIfExists('file')
         self.failUnlessExists('new_name')
 
+    def test_move_unknown_file(self):
+        self.assertRaises(AssertionError,
+                          self.run_script, '$ mv unknown does-not-exist')
+
     def test_move_dir(self):
         self.run_script("""
 $ mkdir dir
@@ -432,7 +436,7 @@
         self.failIfExists('dir')
         self.failUnlessExists('new_name')
         self.failUnlessExists('new_name/file')
-        
+
     def test_move_file_into_dir(self):
         self.run_script("""
 $ mkdir dir



More information about the bazaar-commits mailing list