summaryrefslogtreecommitdiff
path: root/Lib/test/test_largefile.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-03-13 23:42:55 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2009-03-13 23:42:55 +0000
commitd6b11f7d855e77420936405d6fa5b438b60c1b19 (patch)
treecdd6eb4496776e064e825c8d55725ce3a6925615 /Lib/test/test_largefile.py
parentc18824346fd94d5da33fb08d6debd1babe6d1aa6 (diff)
downloadcpython-d6b11f7d855e77420936405d6fa5b438b60c1b19.tar.gz
Issue #5016: FileIO.seekable() could return False if the file position
was negative when truncated to a C int. Patch by Victor Stinner.
Diffstat (limited to 'Lib/test/test_largefile.py')
-rw-r--r--Lib/test/test_largefile.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_largefile.py b/Lib/test/test_largefile.py
index 584a20623f..d9326593a3 100644
--- a/Lib/test/test_largefile.py
+++ b/Lib/test/test_largefile.py
@@ -133,6 +133,15 @@ class LargeFileTest(unittest.TestCase):
f.seek(0)
self.assertEqual(len(f.read()), 1) # else wasn't truncated
+ def test_seekable(self):
+ # Issue #5016; seekable() can return False when the current position
+ # is negative when truncated to an int.
+ for pos in (2**31-1, 2**31, 2**31+1):
+ with self.open(TESTFN, 'rb') as f:
+ f.seek(pos)
+ self.assert_(f.seekable())
+
+
def test_main():
# On Windows and Mac OSX this test comsumes large resources; It
# takes a long time to build the >2GB file and takes >2GB of disk
@@ -172,6 +181,7 @@ def test_main():
with _open(TESTFN, 'wb') as f:
if hasattr(f, 'truncate'):
suite.addTest(TestCase('test_truncate'))
+ suite.addTest(TestCase('test_seekable'))
unlink(TESTFN)
try:
run_unittest(suite)