summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2016-01-06 19:03:15 (GMT)
committerGuido van Rossum <guido@python.org>2016-01-06 19:03:15 (GMT)
commit1a4afec0d66d8843834250836d1056ed6d687385 (patch)
treee7579960c7afc7bffdd08d1fc4f552a47d72fd1b /Lib/test
parent520f297eb4d85a99bee8a22d60c4139b8a443d94 (diff)
parente42823153990ab5a4bb5f9148458cf48e189f4f9 (diff)
downloadcpython-1a4afec0d66d8843834250836d1056ed6d687385.zip
cpython-1a4afec0d66d8843834250836d1056ed6d687385.tar.gz
cpython-1a4afec0d66d8843834250836d1056ed6d687385.tar.bz2
Issue #22570: Add 'path' attribute to pathlib.Path objects. (Merge 3.4->3.5)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_pathlib.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
index 5ee22ad..138550f 100644
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -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, '')