Rev 5251: * ``assertIsDirectory`` has been pulled up to TestCaseWithMemoryTransport. in http://bazaar.launchpad.net/~lifeless/bzr/fetch-proposed

Robert Collins robertc at robertcollins.net
Sat May 22 11:00:51 BST 2010


At http://bazaar.launchpad.net/~lifeless/bzr/fetch-proposed

------------------------------------------------------------
revno: 5251
revision-id: robertc at robertcollins.net-20100522100045-gf2bcx5lkxpxvt2m
parent: robertc at robertcollins.net-20100522094447-5ucgm8tnxbfwoz6o
committer: Robert Collins <robertc at robertcollins.net>
branch nick: fetch-proposed
timestamp: Sat 2010-05-22 22:00:45 +1200
message:
  * ``assertIsDirectory`` has been pulled up to TestCaseWithMemoryTransport.
    (Robert Collins)
=== modified file 'NEWS'
--- a/NEWS	2010-05-21 07:17:13 +0000
+++ b/NEWS	2010-05-22 10:00:45 +0000
@@ -237,6 +237,9 @@
   our first in-tree matcher. See the module docstring for details.
   (Robert Collins)
 
+* ``assertIsDirectory`` has been pulled up to TestCaseWithMemoryTransport.
+  (Robert Collins)
+
 * ``bzr selftest --parallel=subprocess`` now works correctly on win32.
    (Gordon Tyler, #551332)
 

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2010-05-20 18:23:17 +0000
+++ b/bzrlib/tests/__init__.py	2010-05-22 10:00:45 +0000
@@ -2178,6 +2178,21 @@
         self.transport_readonly_server = None
         self.__vfs_server = None
 
+    def assertIsDirectory(self, relpath, transport):
+        """Assert that relpath within transport is a directory.
+
+        This may not be possible on all transports; in that case it propagates
+        a TransportNotPossible.
+        """
+        try:
+            mode = transport.stat(relpath).st_mode
+        except errors.NoSuchFile:
+            self.fail("path %s is not a directory; no such file"
+                      % (relpath))
+        if not stat.S_ISDIR(mode):
+            self.fail("path %s is not a directory; has mode %#o"
+                      % (relpath, mode))
+
     def get_transport(self, relpath=None):
         """Return a writeable transport.
 
@@ -2675,21 +2690,6 @@
             else:
                 return b.create_checkout(relpath, lightweight=True)
 
-    def assertIsDirectory(self, relpath, transport):
-        """Assert that relpath within transport is a directory.
-
-        This may not be possible on all transports; in that case it propagates
-        a TransportNotPossible.
-        """
-        try:
-            mode = transport.stat(relpath).st_mode
-        except errors.NoSuchFile:
-            self.fail("path %s is not a directory; no such file"
-                      % (relpath))
-        if not stat.S_ISDIR(mode):
-            self.fail("path %s is not a directory; has mode %#o"
-                      % (relpath, mode))
-
     def assertTreesEqual(self, left, right):
         """Check that left and right have the same content and properties."""
         # we use a tree delta to check for equality of the content, and we

=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py	2010-05-14 09:48:51 +0000
+++ b/bzrlib/tests/test_selftest.py	2010-05-22 10:00:45 +0000
@@ -526,6 +526,14 @@
             self.test_home_dir)
         self.assertIsSameRealPath(self.test_home_dir, os.environ['HOME'])
 
+    def test_is_directory(self):
+        """Test assertIsDirectory assertion"""
+        t = self.get_transport()
+        self.build_tree(['a_dir/', 'a_file'], transport=t)
+        self.assertIsDirectory('a_dir', t)
+        self.assertRaises(AssertionError, self.assertIsDirectory, 'a_file', t)
+        self.assertRaises(AssertionError, self.assertIsDirectory, 'not_here', t)
+
     def test_cwd_is_TEST_ROOT(self):
         self.assertIsSameRealPath(self.test_dir, self.TEST_ROOT)
         cwd = osutils.getcwd()
@@ -652,14 +660,6 @@
         self.failUnless(isinstance(t2, HttpTransportBase))
         self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))
 
-    def test_is_directory(self):
-        """Test assertIsDirectory assertion"""
-        t = self.get_transport()
-        self.build_tree(['a_dir/', 'a_file'], transport=t)
-        self.assertIsDirectory('a_dir', t)
-        self.assertRaises(AssertionError, self.assertIsDirectory, 'a_file', t)
-        self.assertRaises(AssertionError, self.assertIsDirectory, 'not_here', t)
-
     def test_make_branch_builder(self):
         builder = self.make_branch_builder('dir')
         rev_id = builder.build_commit()




More information about the bazaar-commits mailing list