mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Merge pathlib fixes
This commit is contained in:
commit
006c725426
3 changed files with 27 additions and 4 deletions
|
@ -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
|
||||
|
@ -547,6 +551,9 @@ class _BasePurePathTest(object):
|
|||
self.assertEqual(P('/a/b').with_suffix('.gz'), P('/a/b.gz'))
|
||||
self.assertEqual(P('a/b.py').with_suffix('.gz'), P('a/b.gz'))
|
||||
self.assertEqual(P('/a/b.py').with_suffix('.gz'), P('/a/b.gz'))
|
||||
# Stripping suffix
|
||||
self.assertEqual(P('a/b.py').with_suffix(''), P('a/b'))
|
||||
self.assertEqual(P('/a/b').with_suffix(''), P('/a/b'))
|
||||
# Path doesn't have a "filename" component
|
||||
self.assertRaises(ValueError, P('').with_suffix, '.gz')
|
||||
self.assertRaises(ValueError, P('.').with_suffix, '.gz')
|
||||
|
@ -554,9 +561,12 @@ class _BasePurePathTest(object):
|
|||
# Invalid suffix
|
||||
self.assertRaises(ValueError, P('a/b').with_suffix, 'gz')
|
||||
self.assertRaises(ValueError, P('a/b').with_suffix, '/')
|
||||
self.assertRaises(ValueError, P('a/b').with_suffix, '.')
|
||||
self.assertRaises(ValueError, P('a/b').with_suffix, '/.gz')
|
||||
self.assertRaises(ValueError, P('a/b').with_suffix, 'c/d')
|
||||
self.assertRaises(ValueError, P('a/b').with_suffix, '.c/.d')
|
||||
self.assertRaises(ValueError, P('a/b').with_suffix, './.d')
|
||||
self.assertRaises(ValueError, P('a/b').with_suffix, '.d/.')
|
||||
|
||||
def test_relative_to_common(self):
|
||||
P = self.cls
|
||||
|
@ -950,6 +960,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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue