[Pkg-bazaar-commits] ./bzr/unstable r765: - new test helper check_inventory_shape

Martin Pool mbp at sourcefrog.net
Fri Apr 10 08:20:58 UTC 2009


------------------------------------------------------------
revno: 765
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Fri 2005-06-24 17:05:06 +1000
message:
  - new test helper check_inventory_shape
modified:
  bzrlib/selftest/__init__.py
-------------- next part --------------
=== modified file 'bzrlib/selftest/__init__.py'
--- a/bzrlib/selftest/__init__.py	2005-06-24 05:34:25 +0000
+++ b/bzrlib/selftest/__init__.py	2005-06-24 07:05:06 +0000
@@ -120,8 +120,29 @@
         """Log a message to a progress file"""
         self._log_buf = self._log_buf + str(msg) + '\n'
         print >>self.TEST_LOG, msg
-        
-               
+
+
+    def check_inventory_shape(self, inv, shape):
+        """
+        Compare an inventory to a list of expected names.
+
+        Fail if they are not precisely equal.
+        """
+        extras = []
+        shape = list(shape)             # copy
+        for path, ie in inv.entries():
+            name = path.replace('\\', '/')
+            if ie.kind == 'dir':
+                name = name + '/'
+            if name in shape:
+                shape.remove(name)
+            else:
+                extras.append(name)
+        if shape:
+            self.fail("expcted paths not found in inventory: %r" % shape)
+        if extras:
+            self.fail("unexpected paths found in inventory: %r" % extras)
+
 
 class InTempDir(TestBase):
     """Base class for tests run in a temporary branch."""



More information about the Pkg-bazaar-commits mailing list