~bzr/bzr/readdir

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Robert Collins
  • Date: 2007-03-08 04:38:02 UTC
  • Revision ID: robertc@robertcollins.net-20070308043802-tpk2dyt0n2glwuhs
Restore most of pyrex readdir functionality.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from bzrlib import (
27
27
    errors,
28
28
    osutils,
 
29
    readdir,
29
30
    win32utils,
30
31
    )
31
32
from bzrlib.errors import BzrBadParameterNotUnicode, InvalidURL
767
768
        self._filter_out_stat(result)
768
769
        self.assertEqual(expected_dirblocks, result)
769
770
 
 
771
    def test_readdir(self):
 
772
        tree = [
 
773
            '.bzr/',
 
774
            '0file',
 
775
            '1dir/',
 
776
            '1dir/0file',
 
777
            '1dir/1dir/',
 
778
            '1dir-file',
 
779
            '2file'
 
780
            ]
 
781
        self.build_tree(tree)
 
782
        expected_names = ['.bzr', '0file', '1dir', '1dir-file', '2file']
 
783
        # read_dir either returns None, or a value
 
784
        read_result = readdir.read_dir('.')
 
785
        if read_result[0][1] is None:
 
786
            expected_kind = ['unknown', 'unknown', 'unknown', 'unknown', 'unknown']
 
787
        else:
 
788
            expected_kind = ['directory', 'file', 'directory', 'file', 'file']
 
789
        expected = zip(expected_names, expected_kind)
 
790
        self.assertEqual(expected, sorted(read_result))
 
791
 
770
792
    def assertPathCompare(self, path_less, path_greater):
771
793
        """check that path_less and path_greater compare correctly."""
772
794
        self.assertEqual(0, osutils.compare_paths_prefix_order(