Skip to content

Commit 607b5e3

Browse files
authored
GH-110109: Test pure functionality of pathlib.Path user subclasses (#112242)
Add `PurePathTest` as a superclass of `PathTest`, and therefore also `PathSubclassTest`. This adds coverage of pure functionality in user subclasses of `pathlib.Path`. Remove `PosixPathAsPureTest` and `WindowsPathAsPureTest`, as they now duplicate `PosixPathTest` and `WindowsPathTest`. This makes the MROs of test unit classes match the MROs of pathlib classes.
1 parent 9c7c8ba commit 607b5e3

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

Lib/test/test_pathlib.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -1569,15 +1569,6 @@ class cls(pathlib.PurePath):
15691569
test_repr_roundtrips = None
15701570

15711571

1572-
@only_posix
1573-
class PosixPathAsPureTest(PurePosixPathTest):
1574-
cls = pathlib.PosixPath
1575-
1576-
@only_nt
1577-
class WindowsPathAsPureTest(PureWindowsPathTest):
1578-
cls = pathlib.WindowsPath
1579-
1580-
15811572
#
15821573
# Tests for the virtual classes.
15831574
#
@@ -1771,6 +1762,7 @@ class DummyPathTest(unittest.TestCase):
17711762
#
17721763

17731764
def setUp(self):
1765+
super().setUp()
17741766
pathmod = self.cls.pathmod
17751767
p = self.cls(BASE)
17761768
p.mkdir(parents=True)
@@ -2793,7 +2785,7 @@ class DummyPathWithSymlinksTest(DummyPathTest):
27932785
# Tests for the concrete classes.
27942786
#
27952787

2796-
class PathTest(DummyPathTest):
2788+
class PathTest(DummyPathTest, PurePathTest):
27972789
"""Tests for the FS-accessing functionalities of the Path classes."""
27982790
cls = pathlib.Path
27992791
can_symlink = os_helper.can_symlink()
@@ -3409,7 +3401,7 @@ def test_walk_many_open_files(self):
34093401

34103402

34113403
@only_posix
3412-
class PosixPathTest(PathTest):
3404+
class PosixPathTest(PathTest, PurePosixPathTest):
34133405
cls = pathlib.PosixPath
34143406

34153407
def test_absolute(self):
@@ -3585,7 +3577,7 @@ def test_from_uri_pathname2url(self):
35853577

35863578

35873579
@only_nt
3588-
class WindowsPathTest(PathTest):
3580+
class WindowsPathTest(PathTest, PureWindowsPathTest):
35893581
cls = pathlib.WindowsPath
35903582

35913583
def test_absolute(self):

0 commit comments

Comments
 (0)