diff options
author | Barney Gale <barney.gale@gmail.com> | 2024-01-14 21:49:53 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-14 21:49:53 +0000 |
commit | ca6cf56330ae7751819b62748f33f23d98596703 (patch) | |
tree | 461b2a8b3651a1570736ff9cbed4832671d813bd /Lib/test/test_pathlib/test_pathlib.py | |
parent | c2808431b32fa7bc0d222d4549389f781f1a7333 (diff) | |
download | cpython-ca6cf56330ae7751819b62748f33f23d98596703.tar.gz cpython-ca6cf56330ae7751819b62748f33f23d98596703.zip |
Add `pathlib._abc.PathModuleBase` (#113893)
Path modules provide a subset of the `os.path` API, specifically those
functions needed to provide `PurePathBase` functionality. Each
`PurePathBase` subclass references its path module via a `pathmod` class
attribute.
This commit adds a new `PathModuleBase` class, which provides abstract
methods that unconditionally raise `UnsupportedOperation`. An instance of
this class is assigned to `PurePathBase.pathmod`, replacing `posixpath`.
As a result, `PurePathBase` is no longer POSIX-y by default, and
all its methods raise `UnsupportedOperation` courtesy of `pathmod`.
Users who subclass `PurePathBase` or `PathBase` should choose the path
syntax by setting `pathmod` to `posixpath`, `ntpath`, `os.path`, or their
own subclass of `PathModuleBase`, as circumstances demand.
Diffstat (limited to 'Lib/test/test_pathlib/test_pathlib.py')
-rw-r--r-- | Lib/test/test_pathlib/test_pathlib.py | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index 1b560adfc3b..61d7939ad14 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -1151,6 +1151,7 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest): def test_matches_pathbase_api(self): our_names = {name for name in dir(self.cls) if name[0] != '_'} + our_names.remove('is_reserved') # only present in PurePath path_names = {name for name in dir(pathlib._abc.PathBase) if name[0] != '_'} self.assertEqual(our_names, path_names) for attr_name in our_names: |