/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_urlutils.py

Fix IndexError in urlutils.join with 'http://host/a' and '../../b'.

Show diffs side-by-side

added added

removed removed

Lines of Context:
197
197
            joined = urlutils.join(*args)
198
198
            self.assertEqual(expected, joined)
199
199
 
200
 
        # Test a single element
201
 
        test('foo', 'foo')
202
 
 
203
200
        # Test relative path joining
 
201
        test('foo', 'foo') # relative fragment with nothing is preserved.
204
202
        test('foo/bar', 'foo', 'bar')
205
203
        test('http://foo/bar', 'http://foo', 'bar')
206
204
        test('http://foo/bar', 'http://foo', '.', 'bar')
210
208
        test('http://foo/baz', 'http://foo/bar/', '../baz')
211
209
 
212
210
        # Absolute paths
 
211
        test('http://foo', 'http://foo') # abs url with nothing is preserved.
213
212
        test('http://bar', 'http://foo', 'http://bar')
214
213
        test('sftp://bzr/foo', 'http://foo', 'bar', 'sftp://bzr/foo')
215
214
        test('file:///bar', 'foo', 'file:///bar')
225
224
        
226
225
        # Invalid joinings
227
226
        # Cannot go above root
 
227
        # Implicitly at root:
228
228
        self.assertRaises(InvalidURLJoin, urlutils.join,
229
229
                'http://foo', '../baz')
230
230
        self.assertRaises(InvalidURLJoin, urlutils.join,
231
231
                'http://foo', '/..')
 
232
        # Joining from a path explicitly under the root.
 
233
        self.assertRaises(InvalidURLJoin, urlutils.join,
 
234
                'http://foo/a', '../../b')
232
235
 
233
236
    def test_joinpath(self):
234
237
        def test(expected, *args):