224
224
self.assertRaises(InvalidURLJoin, urlutils.join,
225
225
'http://foo', '../baz')
227
def test_joinpath(self):
228
def test(expected, *args):
229
joined = urlutils.joinpath(*args)
230
self.assertEqual(expected, joined)
232
# Test a single element
235
# Test relative path joining
236
test('foo/bar', 'foo', 'bar')
237
test('foo/bar', 'foo', '.', 'bar')
238
test('foo/baz', 'foo', 'bar', '../baz')
239
test('foo/bar/baz', 'foo', 'bar/baz')
240
test('foo/baz', 'foo', 'bar/../baz')
242
# Test joining to an absolute path
244
test('/foo', '/foo', '.')
245
test('/foo/bar', '/foo', 'bar')
246
test('/', '/foo', '..')
248
# Test joining with an absolute path
249
test('/bar', 'foo', '/bar')
252
# Cannot go above root
253
self.assertRaises(InvalidURLJoin, urlutils.joinpath, '/', '../baz')
227
255
def test_function_type(self):
228
256
if sys.platform == 'win32':
229
257
self.assertEqual(urlutils._win32_local_path_to_url, urlutils.local_path_to_url)