Skip to content

Commit

Permalink
_VirtualPath --> _PathBase
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Jul 12, 2023
1 parent 508cabe commit 2c56591
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ class PureWindowsPath(PurePath):
# Filesystem-accessing classes


class _VirtualPath(PurePath):
class _PathBase(PurePath):
"""PurePath subclass for virtual filesystems, such as archives and remote
storage.
"""
Expand Down Expand Up @@ -1379,7 +1379,7 @@ def as_uri(self):
raise UnsupportedOperation(f"{type(self).__name__}.as_uri()")


class Path(_VirtualPath):
class Path(_PathBase):
"""PurePath subclass that can make system calls.
Path represents a filesystem path but unlike PurePath, also offers
Expand Down
30 changes: 15 additions & 15 deletions Lib/test/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1573,8 +1573,8 @@ def test_group(self):
# Tests for the virtual classes.
#

class VirtualPathTest(PurePathTest):
cls = pathlib._VirtualPath
class PathBaseTest(PurePathTest):
cls = pathlib._PathBase

def test_unsupported_operation(self):
P = self.cls
Expand Down Expand Up @@ -1632,9 +1632,9 @@ def test_as_bytes_common(self):
self.assertRaises(TypeError, bytes, self.cls())


class DummyVirtualPathIO(io.BytesIO):
class DummyPathIO(io.BytesIO):
"""
Used by DummyVirtualPath to implement `open('w')`
Used by DummyPath to implement `open('w')`
"""

def __init__(self, files, path):
Expand All @@ -1647,9 +1647,9 @@ def close(self):
super().close()


class DummyVirtualPath(pathlib._VirtualPath):
class DummyPath(pathlib._PathBase):
"""
Simple implementation of VirtualPath that keeps files and directories in
Simple implementation of PathBase that keeps files and directories in
memory.
"""
_files = {}
Expand Down Expand Up @@ -1691,7 +1691,7 @@ def open(self, mode='r', buffering=-1, encoding=None,
elif mode == 'w':
if parent not in self._directories:
raise FileNotFoundError(errno.ENOENT, "File not found", parent)
stream = DummyVirtualPathIO(self._files, path)
stream = DummyPathIO(self._files, path)
self._files[path] = b''
self._directories[parent].add(name)
else:
Expand Down Expand Up @@ -1724,10 +1724,10 @@ def mkdir(self, mode=0o777, parents=False, exist_ok=False):
raise


class DummyVirtualPathTest(unittest.TestCase):
"""Tests for VirtualPath methods that use stat(), open() and iterdir()."""
class DummyPathTest(unittest.TestCase):
"""Tests for PathBase methods that use stat(), open() and iterdir()."""

cls = DummyVirtualPath
cls = DummyPath
can_symlink = False

# (BASE)
Expand Down Expand Up @@ -2541,7 +2541,7 @@ def test_complex_symlinks_relative_dot_dot(self):
self._check_complex_symlinks(os.path.join('dirA', '..'))


class DummyVirtualPathWithSymlinks(DummyVirtualPath):
class DummyPathWithSymlinks(DummyPath):
def readlink(self):
path = str(self)
if path in self._symlinks:
Expand All @@ -2556,8 +2556,8 @@ def symlink_to(self, target, target_is_directory=False):
self._symlinks[str(self)] = str(target)


class DummyVirtualPathWithSymlinksTest(DummyVirtualPathTest):
cls = DummyVirtualPathWithSymlinks
class DummyPathWithSymlinksTest(DummyPathTest):
cls = DummyPathWithSymlinks
can_symlink = True

def setUp(self):
Expand All @@ -2581,13 +2581,13 @@ def setUp(self):
# Tests for the concrete classes.
#

class PathTest(DummyVirtualPathTest):
class PathTest(DummyPathTest):
"""Tests for the FS-accessing functionalities of the Path classes."""
cls = pathlib.Path
can_symlink = os_helper.can_symlink()

def setUp(self):
# note: this must be kept in sync with `DummyVirtualPathTest.setUp()`
# note: this must be kept in sync with `DummyPathTest.setUp()`
def cleanup():
os.chmod(join('dirE'), 0o777)
os_helper.rmtree(BASE)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Add private ``pathlib._VirtualPath`` class, which provides experimental support
Add private ``pathlib._PathBase`` class, which provides experimental support
for virtual filesystems, and may be made public in a future version of Python.

0 comments on commit 2c56591

Please sign in to comment.