summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_mmap.py
diff options
context:
space:
mode:
authorMarc-André Lemburg <mal@egenix.com>2001-01-17 19:11:13 (GMT)
committerMarc-André Lemburg <mal@egenix.com>2001-01-17 19:11:13 (GMT)
commit3661908a6ac75026e4504d9f62a6ac2e2fb2ec5e (patch)
treeeea0f44df59aaaf014eb4580f1fad308e31601bf /Lib/test/test_mmap.py
parent8551dd60781f738e5e5ef4e22b6f071d27e20b50 (diff)
downloadcpython-3661908a6ac75026e4504d9f62a6ac2e2fb2ec5e.zip
cpython-3661908a6ac75026e4504d9f62a6ac2e2fb2ec5e.tar.gz
cpython-3661908a6ac75026e4504d9f62a6ac2e2fb2ec5e.tar.bz2
This patch removes all uses of "assert" in the regression test suite
and replaces them with a new API verify(). As a result the regression suite will also perform its tests in optimization mode. Written by Marc-Andre Lemburg. Copyright assigned to Guido van Rossum.
Diffstat (limited to 'Lib/test/test_mmap.py')
-rw-r--r--Lib/test/test_mmap.py36
1 files changed, 19 insertions, 17 deletions
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py
index 7c49cf2..4673913 100644
--- a/Lib/test/test_mmap.py
+++ b/Lib/test/test_mmap.py
@@ -1,3 +1,4 @@
+from test_support import verify
import mmap
import string, os, re, sys
@@ -21,15 +22,15 @@ def test_both():
print type(m) # SF bug 128713: segfaulted on Linux
print ' Position of foo:', string.find(m, 'foo') / float(PAGESIZE), 'pages'
- assert string.find(m, 'foo') == PAGESIZE
+ verify(string.find(m, 'foo') == PAGESIZE)
print ' Length of file:', len(m) / float(PAGESIZE), 'pages'
- assert len(m) == 2*PAGESIZE
+ verify(len(m) == 2*PAGESIZE)
print ' Contents of byte 0:', repr(m[0])
- assert m[0] == '\0'
+ verify(m[0] == '\0')
print ' Contents of first 3 bytes:', repr(m[0:3])
- assert m[0:3] == '\0\0\0'
+ verify(m[0:3] == '\0\0\0')
# Modify the file's content
print "\n Modifying file's content..."
@@ -38,11 +39,11 @@ def test_both():
# Check that the modification worked
print ' Contents of byte 0:', repr(m[0])
- assert m[0] == '3'
+ verify(m[0] == '3')
print ' Contents of first 3 bytes:', repr(m[0:3])
- assert m[0:3] == '3\0\0'
+ verify(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'
+ verify(m[PAGESIZE-1 : PAGESIZE + 7] == '\0foobar\0')
m.flush()
@@ -57,19 +58,19 @@ def test_both():
print ' Regex match on mmap (page start, length of match):',
print start / float(PAGESIZE), length
- assert start == PAGESIZE
- assert end == PAGESIZE + 6
+ verify(start == PAGESIZE)
+ verify(end == PAGESIZE + 6)
# test seeking around (try to overflow the seek implementation)
m.seek(0,0)
print ' Seek to zeroth byte'
- assert m.tell() == 0
+ verify(m.tell() == 0)
m.seek(42,1)
print ' Seek to 42nd byte'
- assert m.tell() == 42
+ verify(m.tell() == 42)
m.seek(0,2)
print ' Seek to last byte'
- assert m.tell() == len(m)
+ verify(m.tell() == len(m))
print ' Try to seek to negative position...'
try:
@@ -77,7 +78,7 @@ def test_both():
except ValueError:
pass
else:
- assert 0, 'expected a ValueError but did not get it'
+ verify(0, 'expected a ValueError but did not get it')
print ' Try to seek beyond end of mmap...'
try:
@@ -85,7 +86,7 @@ def test_both():
except ValueError:
pass
else:
- assert 0, 'expected a ValueError but did not get it'
+ verify(0, 'expected a ValueError but did not get it')
print ' Try to seek to negative position...'
try:
@@ -93,7 +94,7 @@ def test_both():
except ValueError:
pass
else:
- assert 0, 'expected a ValueError but did not get it'
+ verify(0, 'expected a ValueError but did not get it')
# Try resizing map
print ' Attempting resize()'
@@ -106,14 +107,15 @@ def test_both():
pass
else:
# resize() is supported
- assert len(m) == 512, "len(m) is %d, but expecting 512" % (len(m),)
+ verify(len(m) == 512,
+ "len(m) is %d, but expecting 512" % (len(m),) )
# Check that we can no longer seek beyond the new size.
try:
m.seek(513,0)
except ValueError:
pass
else:
- assert 0, 'Could seek beyond the new size'
+ verify(0, 'Could seek beyond the new size')
m.close()
os.unlink("foo")