73
73
# Not a valid _win32 url, no drive letter
74
74
self.assertRaises(InvalidURL, from_url, 'file:///path/to/foo')
76
def test_strip_trailing_slash(self):
77
sts = urlutils.strip_trailing_slash
78
if sys.platform == 'win32':
79
self.assertEqual('file:///C|/', sts('file:///C|/'))
80
self.assertEqual('file:///C|/foo', sts('file:///C|/foo'))
81
self.assertEqual('file:///C|/foo', sts('file:///C|/foo/'))
83
self.assertEqual('file:///', sts('file:///'))
84
self.assertEqual('file:///foo', sts('file:///foo'))
85
self.assertEqual('file:///foo', sts('file:///foo/'))
87
self.assertEqual('http://host/', sts('http://host/'))
88
self.assertEqual('http://host/foo', sts('http://host/foo'))
89
self.assertEqual('http://host/foo', sts('http://host/foo/'))
91
# No need to fail just because the slash is missing
92
self.assertEqual('http://host', sts('http://host'))
93
# TODO: jam 20060502 Should this raise InvalidURL?
94
self.assertEqual('file://', sts('file://'))
96
self.assertEqual('random+scheme://user:pass@ahost:port/path',
97
sts('random+scheme://user:pass@ahost:port/path'))
98
self.assertEqual('random+scheme://user:pass@ahost:port/path',
99
sts('random+scheme://user:pass@ahost:port/path/'))
100
self.assertEqual('random+scheme://user:pass@ahost:port/',
101
sts('random+scheme://user:pass@ahost:port/'))
103
# Make sure relative paths work too
104
self.assertEqual('path/to/foo', sts('path/to/foo'))
105
self.assertEqual('path/to/foo', sts('path/to/foo/'))
106
self.assertEqual('../to/foo', sts('../to/foo/'))
107
self.assertEqual('path/../foo', sts('path/../foo/'))
76
109
def test_unescape_for_display(self):
77
110
# Test that URLs are converted to nice unicode strings for display
78
111
disp = urlutils.unescape_for_display