Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into gh-89812-add-lexicalpath
  • Loading branch information
barneygale committed Jun 14, 2023
commit 7e7b5d4670b50ceebacc36c7c4f85f5aaed80859
3 changes: 1 addition & 2 deletions Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,7 @@ def match(self, path_pattern, *, case_sensitive=None):
raise ValueError("empty pattern")



class PurePath(_BasePurePath, os.PathLike):
class PurePath(_BasePurePath):
"""Base class for manipulating paths without I/O.

PurePath represents a filesystem path and offers operations which
Expand Down
34 changes: 12 additions & 22 deletions Lib/test/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,8 @@
# Tests for the pure classes.
#

class _BasePurePathSubclass(object):
def __init__(self, *pathsegments, session_id):
super().__init__(*pathsegments)
self.session_id = session_id

def with_segments(self, *pathsegments):
return type(self)(*pathsegments, session_id=self.session_id)


class _BaseBasePurePathTest(object):
class BasePurePathTest(unittest.TestCase):
cls = pathlib._BasePurePath

# Keys are canonical paths, values are list of tuples of arguments
# supposed to produce equal paths.
Expand Down Expand Up @@ -87,14 +79,6 @@ def test_constructor_common(self):
self.assertEqual(P(P('a'), P('b'), P('c')), P(FakePath("a/b/c")))
self.assertEqual(P(P('./a:b')), P('./a:b'))

def test_concrete_class(self):
if self.cls is pathlib.PurePath:
expected = pathlib.PureWindowsPath if os.name == 'nt' else pathlib.PurePosixPath
else:
expected = self.cls
p = self.cls('a')
self.assertIs(type(p), expected)

def test_different_flavours_unequal(self):
p = self.cls('a')
if p._flavour is posixpath:
Expand Down Expand Up @@ -753,11 +737,17 @@ def test_pickling_common(self):
self.assertEqual(str(pp), str(p))


class BasePurePathTest(_BaseBasePurePathTest, unittest.TestCase):
cls = pathlib._BasePurePath
class PurePathTest(BasePurePathTest):
cls = pathlib.PurePath

def test_concrete_class(self):
if self.cls is pathlib.PurePath:
expected = pathlib.PureWindowsPath if os.name == 'nt' else pathlib.PurePosixPath
else:
expected = self.cls
p = self.cls('a')
self.assertIs(type(p), expected)

class _BasePurePathTest(_BaseBasePurePathTest):
def test_fspath_common(self):
P = self.cls
p = P('a/b')
Expand All @@ -777,7 +767,7 @@ def test_as_uri_common(self):
P().as_uri()


class PurePosixPathTest(_BasePurePathTest, unittest.TestCase):
class PurePosixPathTest(PurePathTest):
cls = pathlib.PurePosixPath

def test_drive_root_parts(self):
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.