mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #22570: Add 'path' attribute to pathlib.Path objects. (Merge 3.4->3.5)
This commit is contained in:
commit
1a4afec0d6
3 changed files with 40 additions and 0 deletions
|
@ -477,6 +477,22 @@ class _BasePurePathTest(object):
|
|||
self.assertEqual(P('a/b.py').name, 'b.py')
|
||||
self.assertEqual(P('/a/b.py').name, 'b.py')
|
||||
|
||||
def test_path_common(self):
|
||||
P = self.cls
|
||||
def check(arg, expected=None):
|
||||
if expected is None:
|
||||
expected = arg
|
||||
self.assertEqual(P(arg).path, expected.replace('/', self.sep))
|
||||
check('', '.')
|
||||
check('.')
|
||||
check('/')
|
||||
check('a/b')
|
||||
check('/a/b')
|
||||
check('/a/b/', '/a/b')
|
||||
check('/a/b/.', '/a/b')
|
||||
check('a/b.py')
|
||||
check('/a/b.py')
|
||||
|
||||
def test_suffix_common(self):
|
||||
P = self.cls
|
||||
self.assertEqual(P('').suffix, '')
|
||||
|
@ -899,6 +915,17 @@ class PureWindowsPathTest(_BasePurePathTest, unittest.TestCase):
|
|||
self.assertEqual(P('//My.py/Share.php').name, '')
|
||||
self.assertEqual(P('//My.py/Share.php/a/b').name, 'b')
|
||||
|
||||
def test_path(self):
|
||||
P = self.cls
|
||||
self.assertEqual(P('c:').path, 'c:')
|
||||
self.assertEqual(P('c:/').path, 'c:\\')
|
||||
self.assertEqual(P('c:a/b').path, 'c:a\\b')
|
||||
self.assertEqual(P('c:/a/b').path, 'c:\\a\\b')
|
||||
self.assertEqual(P('c:a/b.py').path, 'c:a\\b.py')
|
||||
self.assertEqual(P('c:/a/b.py').path, 'c:\\a\\b.py')
|
||||
self.assertEqual(P('//My.py/Share.php').path, '\\\\My.py\\Share.php\\')
|
||||
self.assertEqual(P('//My.py/Share.php/a/b').path, '\\\\My.py\\Share.php\\a\\b')
|
||||
|
||||
def test_suffix(self):
|
||||
P = self.cls
|
||||
self.assertEqual(P('c:').suffix, '')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue