~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/__init__.py

  • Committer: Martin Pool
  • Date: 2005-06-24 07:05:06 UTC
  • Revision ID: mbp@sourcefrog.net-20050624070506-9d01e449dd09edd1
- new test helper check_inventory_shape

Show diffs side-by-side

added added

removed removed

Lines of Context:
120
120
        """Log a message to a progress file"""
121
121
        self._log_buf = self._log_buf + str(msg) + '\n'
122
122
        print >>self.TEST_LOG, msg
123
 
        
124
 
               
 
123
 
 
124
 
 
125
    def check_inventory_shape(self, inv, shape):
 
126
        """
 
127
        Compare an inventory to a list of expected names.
 
128
 
 
129
        Fail if they are not precisely equal.
 
130
        """
 
131
        extras = []
 
132
        shape = list(shape)             # copy
 
133
        for path, ie in inv.entries():
 
134
            name = path.replace('\\', '/')
 
135
            if ie.kind == 'dir':
 
136
                name = name + '/'
 
137
            if name in shape:
 
138
                shape.remove(name)
 
139
            else:
 
140
                extras.append(name)
 
141
        if shape:
 
142
            self.fail("expcted paths not found in inventory: %r" % shape)
 
143
        if extras:
 
144
            self.fail("unexpected paths found in inventory: %r" % extras)
 
145
 
125
146
 
126
147
class InTempDir(TestBase):
127
148
    """Base class for tests run in a temporary branch."""