Skip to content

Commit

Permalink
Fix docstring test
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Dec 16, 2023
1 parent f4facbb commit 60ef4db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
13 changes: 13 additions & 0 deletions Lib/test/test_pathlib/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,19 @@ def tempdir(self):
self.addCleanup(os_helper.rmtree, d)
return d

def test_matches_pathbase_api(self):
our_names = {name for name in dir(self.cls) if name[0] != '_'}
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:
if attr_name == 'pathmod':
# On Windows, Path.pathmod is ntpath, but PathBase.pathmod is
# posixpath, and so their docstrings differ.
continue
our_attr = getattr(self.cls, attr_name)
path_attr = getattr(pathlib._abc.PathBase, attr_name)
self.assertEqual(our_attr.__doc__, path_attr.__doc__)

def test_concrete_class(self):
if self.cls is pathlib.Path:
expected = pathlib.WindowsPath if os.name == 'nt' else pathlib.PosixPath
Expand Down
9 changes: 0 additions & 9 deletions Lib/test/test_pathlib/test_pathlib_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,15 +703,6 @@ def test_fspath_common(self):
def test_as_bytes_common(self):
self.assertRaises(TypeError, bytes, self.cls())

def test_matches_path_api(self):
our_names = {name for name in dir(self.cls) if name[0] != '_'}
path_names = {name for name in dir(pathlib.Path) if name[0] != '_'}
self.assertEqual(our_names, path_names)
for attr_name in our_names:
our_attr = getattr(self.cls, attr_name)
path_attr = getattr(pathlib.Path, attr_name)
self.assertEqual(our_attr.__doc__, path_attr.__doc__)


class DummyPathIO(io.BytesIO):
"""
Expand Down

0 comments on commit 60ef4db

Please sign in to comment.