Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

GH-89812: Improve test for pathlib.Path.stat() #106064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
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
26 changes: 18 additions & 8 deletions 26 Lib/test/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2150,15 +2150,25 @@ def test_resolve_dot(self):
# Non-strict
self.assertEqual(r.resolve(strict=False), p / '3' / '4')

@os_helper.skip_unless_working_chmod
def test_stat(self):
p = self.cls(BASE) / 'fileA'
st = p.stat()
self.assertEqual(p.stat(), st)
# Change file mode by flipping write bit.
p.chmod(st.st_mode ^ 0o222)
self.addCleanup(p.chmod, st.st_mode)
self.assertNotEqual(p.stat(), st)
statA = self.cls(BASE).joinpath('fileA').stat()
statB = self.cls(BASE).joinpath('dirB', 'fileB').stat()
statC = self.cls(BASE).joinpath('dirC').stat()
# st_mode: files are the same, directory differs.
self.assertIsInstance(statA.st_mode, int)
self.assertEqual(statA.st_mode, statB.st_mode)
self.assertNotEqual(statA.st_mode, statC.st_mode)
self.assertNotEqual(statB.st_mode, statC.st_mode)
# st_ino: all different,
self.assertIsInstance(statA.st_ino, int)
self.assertNotEqual(statA.st_ino, statB.st_ino)
self.assertNotEqual(statA.st_ino, statC.st_ino)
self.assertNotEqual(statB.st_ino, statC.st_ino)
# st_dev: all the same.
self.assertIsInstance(statA.st_dev, int)
self.assertEqual(statA.st_dev, statB.st_dev)
self.assertEqual(statA.st_dev, statC.st_dev)
# other attributes not used by pathlib.

@os_helper.skip_unless_symlink
def test_stat_no_follow_symlinks(self):
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.