summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pathlib/test_pathlib_abc.py
diff options
context:
space:
mode:
authorBarney Gale <barney.gale@gmail.com>2024-02-24 19:37:03 (GMT)
committerGitHub <noreply@github.com>2024-02-24 19:37:03 (GMT)
commite3dedeae7abbeda0cb3f1d872ebbb914635d64f2 (patch)
treef4d9a7a39a371d142907e29340420751fbd9f79e /Lib/test/test_pathlib/test_pathlib_abc.py
parent53c5c17e0a97ee06e511c89f1ca6ceb38fd06246 (diff)
downloadcpython-e3dedeae7abbeda0cb3f1d872ebbb914635d64f2.zip
cpython-e3dedeae7abbeda0cb3f1d872ebbb914635d64f2.tar.gz
cpython-e3dedeae7abbeda0cb3f1d872ebbb914635d64f2.tar.bz2
GH-114610: Fix `pathlib.PurePath.with_stem('')` handling of file extensions (#114612)
Raise `ValueError` if `with_stem('')` is called on a path with a file extension. Paths may only have an empty stem if they also have an empty suffix.
Diffstat (limited to 'Lib/test/test_pathlib/test_pathlib_abc.py')
-rw-r--r--Lib/test/test_pathlib/test_pathlib_abc.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/test/test_pathlib/test_pathlib_abc.py b/Lib/test/test_pathlib/test_pathlib_abc.py
index 1d30dec..5bfb76f 100644
--- a/Lib/test/test_pathlib/test_pathlib_abc.py
+++ b/Lib/test/test_pathlib/test_pathlib_abc.py
@@ -957,6 +957,8 @@ class DummyPurePathTest(unittest.TestCase):
self.assertEqual(P('/').with_stem('d'), P('/d'))
self.assertEqual(P('a/b').with_stem(''), P('a/'))
self.assertEqual(P('a/b').with_stem('.'), P('a/.'))
+ self.assertRaises(ValueError, P('foo.gz').with_stem, '')
+ self.assertRaises(ValueError, P('/a/b/foo.gz').with_stem, '')
def test_with_stem_seps(self):
P = self.cls