mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
file size.
This commit is contained in:
parent
df37c8c1ad
commit
7fe60c0a0a
5 changed files with 53 additions and 7 deletions
|
|
@ -311,7 +311,43 @@ def test_both():
|
|||
finally:
|
||||
os.unlink(TESTFN)
|
||||
|
||||
# test mapping of entire file by passing 0 for map length
|
||||
if hasattr(os, "stat"):
|
||||
print " Ensuring that passing 0 as map length sets map size to current file size."
|
||||
f = open(TESTFN, "w+")
|
||||
|
||||
try:
|
||||
f.write(2**16 * 'm') # Arbitrary character
|
||||
f.close()
|
||||
|
||||
f = open(TESTFN, "rb+")
|
||||
mf = mmap.mmap(f.fileno(), 0)
|
||||
verify(len(mf) == 2**16, "Map size should equal file size.")
|
||||
vereq(mf.read(2**16), 2**16 * "m")
|
||||
mf.close()
|
||||
f.close()
|
||||
|
||||
finally:
|
||||
os.unlink(TESTFN)
|
||||
|
||||
# test mapping of entire file by passing 0 for map length
|
||||
if hasattr(os, "stat"):
|
||||
print " Ensuring that passing 0 as map length sets map size to current file size."
|
||||
f = open(TESTFN, "w+")
|
||||
try:
|
||||
f.write(2**16 * 'm') # Arbitrary character
|
||||
f.close()
|
||||
|
||||
f = open(TESTFN, "rb+")
|
||||
mf = mmap.mmap(f.fileno(), 0)
|
||||
verify(len(mf) == 2**16, "Map size should equal file size.")
|
||||
vereq(mf.read(2**16), 2**16 * "m")
|
||||
mf.close()
|
||||
f.close()
|
||||
|
||||
finally:
|
||||
os.unlink(TESTFN)
|
||||
|
||||
print ' Test passed'
|
||||
|
||||
test_both()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue