diff options
author | Barney Gale <barney.gale@gmail.com> | 2024-12-12 17:39:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-12 17:39:24 (GMT) |
commit | 7146f1894638130940944d4808dae7d144d46227 (patch) | |
tree | be8332197a43a5ff0011af924ccd399e4b96c0e0 /Lib/test | |
parent | 487fdbed40734fd7721457c6f6ffeca03da0b0e7 (diff) | |
download | cpython-7146f1894638130940944d4808dae7d144d46227.zip cpython-7146f1894638130940944d4808dae7d144d46227.tar.gz cpython-7146f1894638130940944d4808dae7d144d46227.tar.bz2 |
GH-127807: pathlib ABCs: remove `PathBase._unsupported_msg()` (#127855)
This method helped us customise the `UnsupportedOperation` message
depending on the type. But we're aiming to make `PathBase` a proper ABC
soon, so `NotImplementedError` is the right exception to raise there.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_pathlib/test_pathlib.py | 8 | ||||
-rw-r--r-- | Lib/test/test_pathlib/test_pathlib_abc.py | 12 |
2 files changed, 11 insertions, 9 deletions
diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index b57ef42..68bff2c 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -63,6 +63,14 @@ def needs_symlinks(fn): _tests_needing_symlinks.add(fn.__name__) return fn + + +class UnsupportedOperationTest(unittest.TestCase): + def test_is_notimplemented(self): + self.assertTrue(issubclass(pathlib.UnsupportedOperation, NotImplementedError)) + self.assertTrue(isinstance(pathlib.UnsupportedOperation(), NotImplementedError)) + + # # Tests for the pure classes. # diff --git a/Lib/test/test_pathlib/test_pathlib_abc.py b/Lib/test/test_pathlib/test_pathlib_abc.py index d770b87..e230dd1 100644 --- a/Lib/test/test_pathlib/test_pathlib_abc.py +++ b/Lib/test/test_pathlib/test_pathlib_abc.py @@ -5,7 +5,7 @@ import errno import stat import unittest -from pathlib._abc import UnsupportedOperation, PurePathBase, PathBase +from pathlib._abc import PurePathBase, PathBase from pathlib._types import Parser import posixpath @@ -27,11 +27,6 @@ def needs_windows(fn): return fn -class UnsupportedOperationTest(unittest.TestCase): - def test_is_notimplemented(self): - self.assertTrue(issubclass(UnsupportedOperation, NotImplementedError)) - self.assertTrue(isinstance(UnsupportedOperation(), NotImplementedError)) - # # Tests for the pure classes. # @@ -1294,10 +1289,9 @@ class DummyPurePathTest(unittest.TestCase): class PathBaseTest(PurePathBaseTest): cls = PathBase - def test_unsupported_operation(self): - P = self.cls + def test_not_implemented_error(self): p = self.cls('') - e = UnsupportedOperation + e = NotImplementedError self.assertRaises(e, p.stat) self.assertRaises(e, p.exists) self.assertRaises(e, p.is_dir) |