Skip to content

Commit 946a09c

Browse files
committed
Revert "Remove redundant assert_stat_equal"
This reverts commit e29f458.
1 parent e29f458 commit 946a09c

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎Lib/test/test_os/test_os.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5035,6 +5035,27 @@ def get_entries(self, names):
50355035
self.assertEqual(sorted(entries.keys()), names)
50365036
return entries
50375037

5038+
def assert_stat_equal(self, stat1, stat2, skip_fields):
5039+
if skip_fields:
5040+
for attr in dir(stat1):
5041+
if not attr.startswith("st_"):
5042+
continue
5043+
if attr in ("st_dev", "st_ino", "st_nlink", "st_ctime",
5044+
"st_ctime_ns"):
5045+
continue
5046+
value1 = getattr(stat1, attr)
5047+
value2 = getattr(stat2, attr)
5048+
if attr == "st_file_attributes":
5049+
# Filesystems may report attribute bits that aren't
5050+
# exposed by the stat module.
5051+
value1 &= FILE_ATTRIBUTE_MASK
5052+
value2 &= FILE_ATTRIBUTE_MASK
5053+
self.assertEqual(value1,
5054+
value2,
5055+
(stat1, stat2, attr))
5056+
else:
5057+
self.assertEqual(stat1, stat2)
5058+
50385059
def test_uninstantiable(self):
50395060
scandir_iter = os.scandir(self.path)
50405061
self.assertRaises(TypeError, type(scandir_iter))

0 commit comments

Comments
 (0)