~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_transport.py

(gz) Bug #656170, be more aggressive about closing file handles (Martin [gz])

Show diffs side-by-side

added added

removed removed

Lines of Context:
207
207
                    ]
208
208
        self.build_tree(files, transport=t, line_endings='binary')
209
209
        self.assertRaises(NoSuchFile, t.get, 'c')
210
 
        self.assertListRaises(NoSuchFile, t.get_multi, ['a', 'b', 'c'])
211
 
        self.assertListRaises(NoSuchFile, t.get_multi, iter(['a', 'b', 'c']))
 
210
        def iterate_and_close(func, *args):
 
211
            for f in func(*args):
 
212
                # We call f.read() here because things like paramiko actually
 
213
                # spawn a thread to prefetch the content, which we want to
 
214
                # consume before we close the handle.
 
215
                content = f.read()
 
216
                f.close()
 
217
        self.assertRaises(NoSuchFile, iterate_and_close,
 
218
                          t.get_multi, ['a', 'b', 'c'])
 
219
        self.assertRaises(NoSuchFile, iterate_and_close,
 
220
                          t.get_multi, iter(['a', 'b', 'c']))
212
221
 
213
222
    def test_get_directory_read_gives_ReadError(self):
214
223
        """consistent errors for read() on a file returned by get()."""
1079
1088
        self.assertListRaises(NoSuchFile, t.stat_multi, iter(['a', 'c', 'd']))
1080
1089
        self.build_tree(['subdir/', 'subdir/file'], transport=t)
1081
1090
        subdir = t.clone('subdir')
1082
 
        subdir.stat('./file')
1083
 
        subdir.stat('.')
 
1091
        st = subdir.stat('./file')
 
1092
        st = subdir.stat('.')
1084
1093
 
1085
1094
    def test_hardlink(self):
1086
1095
        from stat import ST_NLINK