mirror of
https://github.com/python/cpython.git
synced 2025-11-01 06:01:29 +00:00
GH-128520: Subclass abc.ABC in pathlib._abc (#128745)
Convert `JoinablePath`, `ReadablePath` and `WritablePath` to real ABCs derived from `abc.ABC`. Make `JoinablePath.parser` abstract, rather than defaulting to `posixpath`. Register `PurePath` and `Path` as virtual subclasses of the ABCs rather than deriving. This avoids a hit to path object instantiation performance. No change of behaviour in the public (non-abstract) classes.
This commit is contained in:
parent
359c7dde3b
commit
a7d41a8947
4 changed files with 125 additions and 49 deletions
|
|
@ -75,7 +75,7 @@ def test_is_notimplemented(self):
|
|||
# Tests for the pure classes.
|
||||
#
|
||||
|
||||
class PurePathTest(test_pathlib_abc.DummyJoinablePathTest):
|
||||
class PurePathTest(test_pathlib_abc.JoinablePathTest):
|
||||
cls = pathlib.PurePath
|
||||
|
||||
# Make sure any symbolic links in the base test path are resolved.
|
||||
|
|
@ -1002,7 +1002,7 @@ class cls(pathlib.PurePath):
|
|||
# Tests for the concrete classes.
|
||||
#
|
||||
|
||||
class PathTest(test_pathlib_abc.DummyRWPathTest, PurePathTest):
|
||||
class PathTest(test_pathlib_abc.RWPathTest, PurePathTest):
|
||||
"""Tests for the FS-accessing functionalities of the Path classes."""
|
||||
cls = pathlib.Path
|
||||
can_symlink = os_helper.can_symlink()
|
||||
|
|
@ -3119,7 +3119,7 @@ def test_group_windows(self):
|
|||
P('c:/').group()
|
||||
|
||||
|
||||
class PathWalkTest(test_pathlib_abc.DummyReadablePathWalkTest):
|
||||
class PathWalkTest(test_pathlib_abc.ReadablePathWalkTest):
|
||||
cls = pathlib.Path
|
||||
base = PathTest.base
|
||||
can_symlink = PathTest.can_symlink
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue