Issue #9850: Fixed macpath.join() for empty first component. Patch by
Oleg Oshmyan.
This commit is contained in:
commit
402e1e388d
|
@ -53,7 +53,7 @@ def join(s, *p):
|
|||
colon = _get_colon(s)
|
||||
path = s
|
||||
for t in p:
|
||||
if (not s) or isabs(t):
|
||||
if (not path) or isabs(t):
|
||||
path = t
|
||||
continue
|
||||
if t[:1] == colon:
|
||||
|
|
|
@ -49,16 +49,40 @@ class MacPathTestCase(unittest.TestCase):
|
|||
def test_join(self):
|
||||
join = macpath.join
|
||||
self.assertEqual(join('a', 'b'), ':a:b')
|
||||
self.assertEqual(join(':a', 'b'), ':a:b')
|
||||
self.assertEqual(join(':a:', 'b'), ':a:b')
|
||||
self.assertEqual(join(':a::', 'b'), ':a::b')
|
||||
self.assertEqual(join(':a', '::b'), ':a::b')
|
||||
self.assertEqual(join('a', ':'), ':a:')
|
||||
self.assertEqual(join('a:', ':'), 'a:')
|
||||
self.assertEqual(join('a', ''), ':a:')
|
||||
self.assertEqual(join('a:', ''), 'a:')
|
||||
self.assertEqual(join('', ''), '')
|
||||
self.assertEqual(join('', 'a:b'), 'a:b')
|
||||
self.assertEqual(join('', 'a', 'b'), ':a:b')
|
||||
self.assertEqual(join('a:b', 'c'), 'a:b:c')
|
||||
self.assertEqual(join('a:b', ':c'), 'a:b:c')
|
||||
self.assertEqual(join('a', ':b', ':c'), ':a:b:c')
|
||||
self.assertEqual(join('a', 'b:'), 'b:')
|
||||
self.assertEqual(join('a:', 'b:'), 'b:')
|
||||
|
||||
self.assertEqual(join(b'a', b'b'), b':a:b')
|
||||
self.assertEqual(join(b':a', b'b'), b':a:b')
|
||||
self.assertEqual(join(b':a:', b'b'), b':a:b')
|
||||
self.assertEqual(join(b':a::', b'b'), b':a::b')
|
||||
self.assertEqual(join(b':a', b'::b'), b':a::b')
|
||||
self.assertEqual(join(b'a', b':'), b':a:')
|
||||
self.assertEqual(join(b'a:', b':'), b'a:')
|
||||
self.assertEqual(join(b'a', b''), b':a:')
|
||||
self.assertEqual(join(b'a:', b''), b'a:')
|
||||
self.assertEqual(join(b'', b''), b'')
|
||||
self.assertEqual(join(b'', b'a:b'), b'a:b')
|
||||
self.assertEqual(join(b'', b'a', b'b'), b':a:b')
|
||||
self.assertEqual(join(b'a:b', b'c'), b'a:b:c')
|
||||
self.assertEqual(join(b'a:b', b':c'), b'a:b:c')
|
||||
self.assertEqual(join(b'a', b':b', b':c'), b':a:b:c')
|
||||
self.assertEqual(join(b'a', b'b:'), b'b:')
|
||||
self.assertEqual(join(b'a:', b'b:'), b'b:')
|
||||
|
||||
def test_splitext(self):
|
||||
splitext = macpath.splitext
|
||||
|
|
Loading…
Reference in New Issue