~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_inv.py

Add an iter_entries_by_dir which returns directory children before their children.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
            ('src/hello.c', 'hello-id'),
80
80
            ], [(path, ie.file_id) for path, ie in inv.iter_entries()])
81
81
            
 
82
    def test_iter_entries_by_dir(self):
 
83
        inv = Inventory()
 
84
        
 
85
        for args in [('src', 'directory', 'src-id'), 
 
86
                     ('doc', 'directory', 'doc-id'), 
 
87
                     ('src/hello.c', 'file', 'hello-id'),
 
88
                     ('src/bye.c', 'file', 'bye-id'),
 
89
                     ('zz', 'file', 'zz-id'),
 
90
                     ('src/sub/', 'directory', 'sub-id'),
 
91
                     ('src/zz.c', 'file', 'zzc-id'),
 
92
                     ('src/sub/a', 'file', 'a-id'),
 
93
                     ('Makefile', 'file', 'makefile-id')]:
 
94
            inv.add_path(*args)
 
95
 
 
96
        self.assertEqual([
 
97
            ('Makefile', 'makefile-id'),
 
98
            ('doc', 'doc-id'),
 
99
            ('src', 'src-id'),
 
100
            ('zz', 'zz-id'),
 
101
            ('src/bye.c', 'bye-id'),
 
102
            ('src/hello.c', 'hello-id'),
 
103
            ('src/sub', 'sub-id'),
 
104
            ('src/zz.c', 'zzc-id'),
 
105
            ('src/sub/a', 'a-id'),
 
106
            ], [(path, ie.file_id) for path, ie in inv.iter_entries_by_dir()])
 
107
            
82
108
    def test_version(self):
83
109
        """Inventory remembers the text's version."""
84
110
        inv = Inventory()