summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pathlib.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-07-07 01:37:15 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-07-07 01:37:15 (GMT)
commite50dafcd636ba32db890600164698bb070d40d97 (patch)
treea5c1283b9830358f11b61d6bb624f82bb98f5c60 /Lib/test/test_pathlib.py
parent7084e736db318ba83a879e2e93e7c76264e48dbf (diff)
downloadcpython-e50dafcd636ba32db890600164698bb070d40d97.zip
cpython-e50dafcd636ba32db890600164698bb070d40d97.tar.gz
cpython-e50dafcd636ba32db890600164698bb070d40d97.tar.bz2
Issue #20639: calling Path.with_suffix('') allows removing the suffix again.
Patch by July Tikhonov.
Diffstat (limited to 'Lib/test/test_pathlib.py')
-rw-r--r--Lib/test/test_pathlib.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
index 2c3fce7..da001f0 100644
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -551,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')
@@ -558,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