~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport_implementations.py

  • Committer: Robert Collins
  • Date: 2006-09-29 06:24:03 UTC
  • mto: This revision was merged to the branch mainline in revision 2587.
  • Revision ID: robertc@robertcollins.net-20060929062403-7e8b779181d8766c
``Transport.get`` has had its interface made more clear for ease of use.
Retrieval of a directory must now fail with either 'PathError' at open
time, or raise 'ReadError' on a read. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
122
122
        self.assertListRaises(NoSuchFile, t.get_multi, ['a', 'b', 'c'])
123
123
        self.assertListRaises(NoSuchFile, t.get_multi, iter(['a', 'b', 'c']))
124
124
 
 
125
    def test_get_directory(self):
 
126
        """get() of a directory should only error when read() is called."""
 
127
        t = self.get_transport()
 
128
        if t.is_readonly():
 
129
            self.build_tree(['a directory/'])
 
130
        else:
 
131
            t.mkdir('a%20directory')
 
132
        # getting the file must either work or fail with a PathError
 
133
        try:
 
134
            a_file = t.get('a%20directory')
 
135
        except errors.PathError:
 
136
            # early failure return immediately.
 
137
            return
 
138
        # having got a file, read() must either work (i.e. http reading a dir listing) or
 
139
        # fail with ReadError
 
140
        try:
 
141
            a_file.read()
 
142
        except errors.ReadError:
 
143
            pass
 
144
 
125
145
    def test_get_bytes(self):
126
146
        t = self.get_transport()
127
147