~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_transport.py

  • Committer: Vincent Ladeuil
  • Date: 2011-07-06 09:22:00 UTC
  • mfrom: (6008 +trunk)
  • mto: (6012.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6013.
  • Revision ID: v.ladeuil+lp@free.fr-20110706092200-7iai2mwzc0sqdsvf
MergingĀ inĀ trunk

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
1617
1626
    def test_readv(self):
1618
1627
        transport = self.get_transport()
1619
1628
        if transport.is_readonly():
1620
 
            file('a', 'w').write('0123456789')
 
1629
            with file('a', 'w') as f: f.write('0123456789')
1621
1630
        else:
1622
1631
            transport.put_bytes('a', '0123456789')
1623
1632
 
1633
1642
    def test_readv_out_of_order(self):
1634
1643
        transport = self.get_transport()
1635
1644
        if transport.is_readonly():
1636
 
            file('a', 'w').write('0123456789')
 
1645
            with file('a', 'w') as f: f.write('0123456789')
1637
1646
        else:
1638
1647
            transport.put_bytes('a', '01234567890')
1639
1648
 
1711
1720
        transport = self.get_transport()
1712
1721
        # test from observed failure case.
1713
1722
        if transport.is_readonly():
1714
 
            file('a', 'w').write('a'*1024*1024)
 
1723
            with file('a', 'w') as f: f.write('a'*1024*1024)
1715
1724
        else:
1716
1725
            transport.put_bytes('a', 'a'*1024*1024)
1717
1726
        broken_vector = [(465219, 800), (225221, 800), (445548, 800),
1751
1760
    def test_readv_short_read(self):
1752
1761
        transport = self.get_transport()
1753
1762
        if transport.is_readonly():
1754
 
            file('a', 'w').write('0123456789')
 
1763
            with file('a', 'w') as f: f.write('0123456789')
1755
1764
        else:
1756
1765
            transport.put_bytes('a', '01234567890')
1757
1766