diff options
| author | Barney Gale <barney.gale@gmail.com> | 2024-01-30 14:25:16 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-30 14:25:16 (GMT) |
| commit | 809eed48058ea7391df57ead09dff53bcc5d81e9 (patch) | |
| tree | 310860ec40ccf4fa8d5996e52907979a7a8163c9 /Lib/test/test_pathlib/test_pathlib_abc.py | |
| parent | e21754d7f8336d4647e28f355d8a3dbd5a2c7545 (diff) | |
| download | cpython-809eed48058ea7391df57ead09dff53bcc5d81e9.zip cpython-809eed48058ea7391df57ead09dff53bcc5d81e9.tar.gz cpython-809eed48058ea7391df57ead09dff53bcc5d81e9.tar.bz2 | |
GH-114610: Fix `pathlib._abc.PurePathBase.with_suffix('.ext')` handling of stems (#114613)
Raise `ValueError` if `with_suffix('.ext')` is called on a path without a
stem. Paths may only have a non-empty suffix if they also have a non-empty
stem.
ABC-only bugfix; no effect on public classes.
Diffstat (limited to 'Lib/test/test_pathlib/test_pathlib_abc.py')
| -rw-r--r-- | Lib/test/test_pathlib/test_pathlib_abc.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Lib/test/test_pathlib/test_pathlib_abc.py b/Lib/test/test_pathlib/test_pathlib_abc.py index ab989cb..18a612f 100644 --- a/Lib/test/test_pathlib/test_pathlib_abc.py +++ b/Lib/test/test_pathlib/test_pathlib_abc.py @@ -977,9 +977,8 @@ class DummyPurePathTest(unittest.TestCase): def test_with_suffix_empty(self): P = self.cls # Path doesn't have a "filename" component. - self.assertEqual(P('').with_suffix('.gz'), P('.gz')) - self.assertEqual(P('.').with_suffix('.gz'), P('..gz')) - self.assertEqual(P('/').with_suffix('.gz'), P('/.gz')) + self.assertRaises(ValueError, P('').with_suffix, '.gz') + self.assertRaises(ValueError, P('/').with_suffix, '.gz') def test_with_suffix_seps(self): P = self.cls |
