60
60
self.assertEqual('foo', basename('path/../foo'))
61
61
self.assertEqual('foo', basename('../path/foo'))
63
def test_normalize_url(self):
66
def test_url_scheme_re(self):
67
# Test paths that may be URLs
68
def test_one(url, scheme_and_path):
69
"""Assert that _url_scheme_re correctly matches
71
:param scheme_and_path: The (scheme, path) that should be matched
72
can be None, to indicate it should not match
74
m = urlutils._url_scheme_re.match(url)
75
if scheme_and_path is None:
76
self.assertEqual(None, m)
78
self.assertEqual(scheme_and_path[0], m.group('scheme'))
79
self.assertEqual(scheme_and_path[1], m.group('path'))
82
test_one('/path', None)
83
test_one('C:/path', None)
84
test_one('../path/to/foo', None)
85
test_one(u'../path/to/fo\xe5', None)
88
test_one('http://host/path/', ('http', 'host/path/'))
89
test_one('sftp://host/path/to/foo', ('sftp', 'host/path/to/foo'))
90
test_one('file:///usr/bin', ('file', '/usr/bin'))
91
test_one('file:///C:/Windows', ('file', '/C:/Windows'))
92
test_one('file:///C|/Windows', ('file', '/C|/Windows'))
93
test_one(u'readonly+sftp://host/path/\xe5', ('readonly+sftp', u'host/path/\xe5'))
96
# Can't have slashes or colons in the scheme
97
test_one('/path/to/://foo', None)
98
test_one('path:path://foo', None)
99
# Must have more than one character for scheme
100
test_one('C://foo', None)
101
test_one('ab://foo', ('ab', 'foo'))
63
103
def test_dirname(self):
64
104
# Test bzrlib.urlutils.dirname()
65
105
dirname = urlutils.dirname