summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pathlib.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-07-07 01:31:12 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-07-07 01:31:12 (GMT)
commit7084e736db318ba83a879e2e93e7c76264e48dbf (patch)
tree9cbd1206a5f55d5d23a50ff7b481db36b5a7e01c /Lib/test/test_pathlib.py
parent7bc5fb6916b59e9d6e491c8519e5affa98b8aa6c (diff)
downloadcpython-7084e736db318ba83a879e2e93e7c76264e48dbf.zip
cpython-7084e736db318ba83a879e2e93e7c76264e48dbf.tar.gz
cpython-7084e736db318ba83a879e2e93e7c76264e48dbf.tar.bz2
Issue #21714: Disallow the construction of invalid paths using Path.with_name(). Original patch by Antony Lee.
Diffstat (limited to 'Lib/test/test_pathlib.py')
-rw-r--r--Lib/test/test_pathlib.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
index 6378d8c..2c3fce7 100644
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -540,6 +540,10 @@ class _BasePurePathTest(object):
self.assertRaises(ValueError, P('').with_name, 'd.xml')
self.assertRaises(ValueError, P('.').with_name, 'd.xml')
self.assertRaises(ValueError, P('/').with_name, 'd.xml')
+ self.assertRaises(ValueError, P('a/b').with_name, '')
+ self.assertRaises(ValueError, P('a/b').with_name, '/c')
+ self.assertRaises(ValueError, P('a/b').with_name, 'c/')
+ self.assertRaises(ValueError, P('a/b').with_name, 'c/d')
def test_with_suffix_common(self):
P = self.cls
@@ -950,6 +954,10 @@ class PureWindowsPathTest(_BasePurePathTest, unittest.TestCase):
self.assertRaises(ValueError, P('c:').with_name, 'd.xml')
self.assertRaises(ValueError, P('c:/').with_name, 'd.xml')
self.assertRaises(ValueError, P('//My/Share').with_name, 'd.xml')
+ self.assertRaises(ValueError, P('c:a/b').with_name, 'd:')
+ self.assertRaises(ValueError, P('c:a/b').with_name, 'd:e')
+ self.assertRaises(ValueError, P('c:a/b').with_name, 'd:/e')
+ self.assertRaises(ValueError, P('c:a/b').with_name, '//My/Share')
def test_with_suffix(self):
P = self.cls