diff options
author | Jesus Cea <jcea@jcea.es> | 2012-04-26 16:39:35 +0200 |
---|---|---|
committer | Jesus Cea <jcea@jcea.es> | 2012-04-26 16:39:35 +0200 |
commit | f70b6cbfd343ebb618ca57f07dbc60d007da170c (patch) | |
tree | ee976366627fc00e737c9b72e33224e5127aa682 /Lib/test/test_posix.py | |
parent | d06969da47eef524bd2e9adf18fbed8638931f31 (diff) | |
download | cpython-f70b6cbfd343ebb618ca57f07dbc60d007da170c.tar.gz |
Close #10142: Support for SEEK_HOLE/SEEK_DATA
Diffstat (limited to 'Lib/test/test_posix.py')
-rw-r--r-- | Lib/test/test_posix.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index 142dddd09b..c8798a9a93 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -1009,6 +1009,26 @@ class PosixTester(unittest.TestCase): posix.RTLD_GLOBAL posix.RTLD_LOCAL + @unittest.skipUnless('PC_MIN_HOLE_SIZE' in os.pathconf_names, + "test needs an OS that reports file holes") + def test_fs_holes(self) : + # Even if the filesystem doesn't report holes, + # if the OS supports it the SEEK_* constants + # will be defined and will have a consistent + # behaviour: + # os.SEEK_DATA = current position + # os.SEEK_HOLE = end of file position + with open(support.TESTFN, 'r+b') as fp : + fp.write(b"hello") + fp.flush() + size = fp.tell() + fno = fp.fileno() + for i in range(size) : + self.assertEqual(i, os.lseek(fno, i, os.SEEK_DATA)) + self.assertLessEqual(size, os.lseek(fno, i, os.SEEK_HOLE)) + self.assertRaises(OSError, os.lseek, fno, size, os.SEEK_DATA) + self.assertRaises(OSError, os.lseek, fno, size, os.SEEK_HOLE) + class PosixGroupsTester(unittest.TestCase): def setUp(self): |