summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_mmap.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-10-23 17:22:08 (GMT)
committerFred Drake <fdrake@acm.org>2000-10-23 17:22:08 (GMT)
commit004d5e6880940ddbb38460986ac62ee0f1bae97d (patch)
tree682e75e743f5c22206a65ac0262c03ce37e4fbee /Lib/test/test_mmap.py
parent2e6d25c5bbf3e2d4f18191c0836b5ed8f94dc850 (diff)
downloadcpython-004d5e6880940ddbb38460986ac62ee0f1bae97d.zip
cpython-004d5e6880940ddbb38460986ac62ee0f1bae97d.tar.gz
cpython-004d5e6880940ddbb38460986ac62ee0f1bae97d.tar.bz2
Make reindent.py happy (convert everything to 4-space indents!).
Diffstat (limited to 'Lib/test/test_mmap.py')
-rw-r--r--Lib/test/test_mmap.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py
index 449c674..3e2d89f 100644
--- a/Lib/test/test_mmap.py
+++ b/Lib/test/test_mmap.py
@@ -1,4 +1,3 @@
-
import mmap
import string, os, re, sys
@@ -6,10 +5,10 @@ PAGESIZE = mmap.PAGESIZE
def test_both():
"Test mmap module on Unix systems and Windows"
-
+
# Create an mmap'ed file
f = open('foo', 'w+')
-
+
# Write 2 pages worth of data to the file
f.write('\0'* PAGESIZE)
f.write('foo')
@@ -17,11 +16,11 @@ def test_both():
m = mmap.mmap(f.fileno(), 2 * PAGESIZE)
f.close()
-
+
# Simple sanity checks
print ' Position of foo:', string.find(m, 'foo') / float(PAGESIZE), 'pages'
assert string.find(m, 'foo') == PAGESIZE
-
+
print ' Length of file:', len(m) / float(PAGESIZE), 'pages'
assert len(m) == 2*PAGESIZE
@@ -29,12 +28,12 @@ def test_both():
assert m[0] == '\0'
print ' Contents of first 3 bytes:', repr(m[0:3])
assert m[0:3] == '\0\0\0'
-
+
# Modify the file's content
print "\n Modifying file's content..."
m[0] = '3'
m[PAGESIZE +3: PAGESIZE +3+3]='bar'
-
+
# Check that the modification worked
print ' Contents of byte 0:', repr(m[0])
assert m[0] == '3'
@@ -42,7 +41,7 @@ def test_both():
assert m[0:3] == '3\0\0'
print ' Contents of second page:', repr(m[PAGESIZE-1 : PAGESIZE + 7])
assert m[PAGESIZE-1 : PAGESIZE + 7] == '\0foobar\0'
-
+
m.flush()
# Test doing a regular expression match in an mmap'ed file
@@ -51,11 +50,11 @@ def test_both():
print ' ERROR: regex match on mmap failed!'
else:
start, end = match.span(0)
- length = end - start
+ length = end - start
print ' Regex match on mmap (page start, length of match):',
print start / float(PAGESIZE), length
-
+
assert start == PAGESIZE
assert end == PAGESIZE + 6
@@ -113,7 +112,7 @@ def test_both():
pass
else:
assert 0, 'Could seek beyond the new size'
-
+
m.close()
os.unlink("foo")
print ' Test passed'