/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Robert Collins
  • Date: 2006-06-08 16:12:13 UTC
  • mto: (1755.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1754.
  • Revision ID: robertc@robertcollins.net-20060608161213-b0cbafde5ba51708
(rbc, jam, mbp)Add bzrlib.osutils.walkdirs, an optimised walk-and-stat routine.

Show diffs side-by-side

added added

removed removed

Lines of Context:
220
220
    def test_split_with_carriage_returns(self):
221
221
        self.assertEqual(['foo\rbar\n'],
222
222
                         osutils.split_lines('foo\rbar\n'))
 
223
 
 
224
 
 
225
class TestWalkDirs(TestCaseInTempDir):
 
226
 
 
227
    def test_walkdirs(self):
 
228
        tree = [
 
229
            '.bzr',
 
230
            '0file',
 
231
            '1dir/',
 
232
            '1dir/0file',
 
233
            '1dir/1dir/',
 
234
            '2file'
 
235
            ]
 
236
        self.build_tree(tree)
 
237
        expected_dirblocks = [
 
238
                [
 
239
                    ('0file', '0file', 'file'),
 
240
                    ('1dir', '1dir', 'directory'),
 
241
                    ('2file', '2file', 'file'),
 
242
                ],
 
243
                [
 
244
                    ('1dir/0file', '0file', 'file'),
 
245
                    ('1dir/1dir', '1dir', 'directory'),
 
246
                ],
 
247
                [
 
248
                ],
 
249
            ]
 
250
        result = []
 
251
        found_bzrdir = False
 
252
        for dirblock in osutils.walkdirs('.'):
 
253
            if len(dirblock) and dirblock[0][1] == '.bzr':
 
254
                # this tests the filtering of selected paths
 
255
                found_bzrdir = True
 
256
                del dirblock[0]
 
257
            result.append(dirblock)
 
258
 
 
259
        self.assertTrue(found_bzrdir)
 
260
        self.assertEqual(expected_dirblocks,
 
261
            [[line[0:3] for line in block] for block in result])