summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2012-06-22 16:48:08 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2012-06-22 16:48:08 (GMT)
commit67064bc1b6b4fb71e1698dc898b9f7d8065a4a70 (patch)
treee3bf4ab1c64589dd2a2e29af029163993e363f0d /Lib/test
parenta2637729f23dc993e820fd92f0d1759ad714c9b2 (diff)
parent9436361e4cdd7d3dc5f42674b54995c4915afb59 (diff)
downloadcpython-67064bc1b6b4fb71e1698dc898b9f7d8065a4a70.zip
cpython-67064bc1b6b4fb71e1698dc898b9f7d8065a4a70.tar.gz
cpython-67064bc1b6b4fb71e1698dc898b9f7d8065a4a70.tar.bz2
merge
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_io.py2
-rw-r--r--Lib/test/test_posix.py20
2 files changed, 21 insertions, 1 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 1951a06..54ba179 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -706,7 +706,7 @@ class CommonBufferedTests:
bufio = self.tp(rawio)
# Invalid whence
self.assertRaises(ValueError, bufio.seek, 0, -1)
- self.assertRaises(ValueError, bufio.seek, 0, 3)
+ self.assertRaises(ValueError, bufio.seek, 0, 9)
def test_override_destructor(self):
tp = self.tp
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 21473fc..ae46866 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -1015,6 +1015,26 @@ class PosixTester(unittest.TestCase):
posix.RTLD_GLOBAL
posix.RTLD_LOCAL
+ @unittest.skipUnless(hasattr(os, 'SEEK_HOLE'),
+ "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):