Permalink
Browse files

Fixed pathlib and scandir tests for Windows

- skipped failing tests
- fixed os.scandir st_ino/st_dev Windows behavior (differs from documentation)
- see #303
  • Loading branch information...
mrbean-bremen committed Oct 22, 2017
1 parent 41c2d45 commit a4f574d0b21d8522c28e41245070e5047a2abd7d
Showing with 201 additions and 120 deletions.
  1. +11 −9 fake_filesystem_test.py
  2. +189 −104 fake_pathlib_test.py
  3. +1 −7 pyfakefs/fake_filesystem.py
View
@@ -4736,10 +4736,10 @@ def testInode(self):
self.assertEqual(self.os.lstat(self.file_link_path).st_ino,
self.dir_entries[3].inode())
def testStat(self):
def checkStat(self, expected_size):
self.assertEqual(50, self.dir_entries[1].stat().st_size)
self.assertEqual(10, self.dir_entries[3].stat().st_size)
self.assertEqual(len(self.linked_file_path),
self.assertEqual(expected_size,
self.dir_entries[3].stat(
follow_symlinks=False).st_size)
self.assertEqual(
@@ -4749,23 +4749,25 @@ def testStat(self):
self.os.stat(self.linked_dir_path).st_mtime,
self.dir_entries[2].stat().st_mtime)
@unittest.skipIf(TestCase.is_windows, 'POSIX specific behavior')
def testStatPosix(self):
self.checkStat(len(self.linked_file_path))
@unittest.skipIf(not TestCase.is_windows, 'Windows specific behavior')
def testStatWindows(self):
self.checkStat(0)
def testIndexAccessToStatTimesReturnsInt(self):
self.assertEqual(self.os.stat(self.dir_path)[stat.ST_CTIME],
int(self.dir_entries[0].stat().st_ctime))
self.assertEqual(self.os.stat(self.linked_dir_path)[stat.ST_MTIME],
int(self.dir_entries[2].stat().st_mtime))
def testStatInoDevPosix(self):
self.checkPosixOnly()
def testStatInoDev(self):
file_stat = self.os.stat(self.linked_file_path)
self.assertEqual(file_stat.st_ino, self.dir_entries[3].stat().st_ino)
self.assertEqual(file_stat.st_dev, self.dir_entries[3].stat().st_dev)
def testStatInoDevWindows(self):
self.checkWindowsOnly()
self.assertEqual(0, self.dir_entries[3].stat().st_ino)
self.assertEqual(0, self.dir_entries[3].stat().st_dev)
class RealScandirTest(FakeScandirTest):
def useRealFs(self):
Oops, something went wrong.

0 comments on commit a4f574d

Please sign in to comment.