~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Robert Collins
  • Date: 2006-06-16 16:17:40 UTC
  • mto: (1780.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1781.
  • Revision ID: robertc@robertcollins.net-20060616161740-35004ca04a864e3a
Add new tests John Meinel asked for.

Show diffs side-by-side

added added

removed removed

Lines of Context:
305
305
        self.assertPathCompare("a/z", "z/z")
306
306
        self.assertPathCompare("a/c/z", "a/d/e")
307
307
 
 
308
    def test_path_prefix_sorting(self):
 
309
        """Doing a sort on path prefix should match our sample data."""
 
310
        original_paths = [
 
311
            'a',
 
312
            'a/b',
 
313
            'a/b/c',
 
314
            'b',
 
315
            'b/c',
 
316
            'd',
 
317
            'd/e',
 
318
            'd/e/f',
 
319
            'd/f',
 
320
            'd/g',
 
321
            'g',
 
322
            ]
 
323
 
 
324
        dir_sorted_paths = [
 
325
            'a',
 
326
            'b',
 
327
            'd',
 
328
            'g',
 
329
            'a/b',
 
330
            'a/b/c',
 
331
            'b/c',
 
332
            'd/e',
 
333
            'd/f',
 
334
            'd/g',
 
335
            'd/e/f',
 
336
            ]
 
337
 
 
338
        self.assertEqual(
 
339
            dir_sorted_paths,
 
340
            sorted(original_paths, key=osutils.path_prefix_key))
 
341
        # using the comparison routine shoudl work too:
 
342
        self.assertEqual(
 
343
            dir_sorted_paths,
 
344
            sorted(original_paths, cmp=osutils.compare_paths_prefix_order))