summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-06-30 00:07:28 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-06-30 00:07:28 (GMT)
commitde68722ca06615692613148b7015b3c62cd043c3 (patch)
tree40ee136de88cdf028fcc75ca03422b77a6a2fc90 /Lib
parentd95224ceaf61b6c4cbc7fd8e851a1268f6eee914 (diff)
downloadcpython-de68722ca06615692613148b7015b3c62cd043c3.zip
cpython-de68722ca06615692613148b7015b3c62cd043c3.tar.gz
cpython-de68722ca06615692613148b7015b3c62cd043c3.tar.bz2
Issue #21679: Prevent extraneous fstat() calls during open(). Patch by Bohuslav Kabrda.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_fileio.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py
index c37482e..b87dc07 100644
--- a/Lib/test/test_fileio.py
+++ b/Lib/test/test_fileio.py
@@ -60,6 +60,15 @@ class AutoFileTests(unittest.TestCase):
self.assertRaises((AttributeError, TypeError),
setattr, f, attr, 'oops')
+ def testBlksize(self):
+ # test private _blksize attribute
+ blksize = io.DEFAULT_BUFFER_SIZE
+ # try to get preferred blksize from stat.st_blksize, if available
+ if hasattr(os, 'fstat'):
+ fst = os.fstat(self.f.fileno())
+ blksize = getattr(fst, 'st_blksize', blksize)
+ self.assertEqual(self.f._blksize, blksize)
+
def testReadinto(self):
# verify readinto
self.f.write(bytes([1, 2]))
@@ -141,7 +150,7 @@ class AutoFileTests(unittest.TestCase):
def testOpendir(self):
# Issue 3703: opening a directory should fill the errno
# Windows always returns "[Errno 13]: Permission denied
- # Unix calls dircheck() and returns "[Errno 21]: Is a directory"
+ # Unix uses fstat and returns "[Errno 21]: Is a directory"
try:
_FileIO('.', 'r')
except OSError as e: