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.
This commit is contained in:
Marc-André Lemburg 2001-01-17 19:11:13 +00:00
parent 8551dd6078
commit 3661908a6a
70 changed files with 436 additions and 412 deletions

View File

@ -3,7 +3,7 @@
Roger E. Masse
"""
import al
from test_support import verbose
from test_support import verify, verbose
alattrs = ['__doc__', '__name__', 'getdefault', 'getminmax', 'getname', 'getparams',
'newconfig', 'openport', 'queryparams', 'setparams']

View File

@ -3,7 +3,7 @@
Roger E. Masse
"""
import array
from test_support import verbose, TESTFN, unlink, TestFailed
from test_support import verify, verbose, TESTFN, unlink, TestFailed
def main():

View File

@ -1,5 +1,5 @@
# Test the exit module
from test_support import verbose
from test_support import verify, verbose
import atexit
def handler1():

View File

@ -1,6 +1,6 @@
# Test audioop.
import audioop
from test_support import verbose
from test_support import verify, verbose
def gendata1():
return '\0\1\2'

View File

@ -267,7 +267,7 @@ if tuple(xrange(0,10,2)) != tuple(range(0,10,2)):
raise TestFailed, 'xrange(0,10,2)'
# regression tests for SourceForge bug #121695
def _range_test(r):
assert r.start != r.stop, 'Test not valid for passed-in xrange object.'
verify(r.start != r.stop, 'Test not valid for passed-in xrange object.')
if r.stop in r:
raise TestFailed, 'r.stop in ' + `r`
if r.stop-r.step not in r:

View File

@ -1,6 +1,6 @@
"""Test the binascii C module."""
from test_support import verbose
from test_support import verify, verbose
import binascii
# Show module doc string
@ -42,7 +42,7 @@ res = ""
for line in lines:
b = binascii.a2b_base64(line)
res = res + b
assert res == testdata
verify(res == testdata)
# Test base64 with random invalid characters sprinkled throughout
# (This requires a new version of binascii.)
@ -67,7 +67,7 @@ res = ""
for line in map(addnoise, lines):
b = binascii.a2b_base64(line)
res = res + b
assert res == testdata
verify(res == testdata)
# Test uu
print "uu test"
@ -82,7 +82,7 @@ res = ""
for line in lines:
b = binascii.a2b_uu(line)
res = res + b
assert res == testdata
verify(res == testdata)
# Test crc32()
crc = binascii.crc32("Test the CRC-32 of")

View File

@ -6,7 +6,7 @@
"""
import binhex
import tempfile
from test_support import verbose, TestSkipped
from test_support import verify, verbose, TestSkipped
def test():

View File

@ -6,7 +6,7 @@
import os
import bsddb
import tempfile
from test_support import verbose
from test_support import verify, verbose
def test(openmethod, what):

View File

@ -13,7 +13,7 @@ from test_support import TestFailed, TESTFN
def drive_one(pattern, length):
q, r = divmod(length, len(pattern))
teststring = pattern * q + pattern[:r]
assert len(teststring) == length
verify(len(teststring) == length)
try_one(teststring)
try_one(teststring + "x")
try_one(teststring[:-1])

View File

@ -3,7 +3,7 @@
Roger E. Masse
"""
import cd
from test_support import verbose
from test_support import verify, verbose
cdattrs = ['BLOCKSIZE', 'CDROM', 'DATASIZE', 'ERROR', 'NODISC', 'PAUSED', 'PLAYING', 'READY',
'STILL', '__doc__', '__name__', 'atime', 'audio', 'catalog', 'control', 'createparser', 'error',

View File

@ -1,3 +1,4 @@
from test_support import verify, verbose
import cgi
import os
import sys
@ -117,9 +118,9 @@ def main():
# Test basic parsing
print repr(orig)
d = do_test(orig, "GET")
assert d == expect, "Error parsing %s" % repr(orig)
verify(d == expect, "Error parsing %s" % repr(orig))
d = do_test(orig, "POST")
assert d == expect, "Error parsing %s" % repr(orig)
verify(d == expect, "Error parsing %s" % repr(orig))
env = {'QUERY_STRING': orig}
fcd = cgi.FormContentDict(env)
@ -127,21 +128,21 @@ def main():
fs = cgi.FieldStorage(environ=env)
if type(expect) == type({}):
# test dict interface
assert len(expect) == len(fcd)
assert norm(expect.keys()) == norm(fcd.keys())
assert norm(expect.values()) == norm(fcd.values())
assert norm(expect.items()) == norm(fcd.items())
assert fcd.get("nonexistent field", "default") == "default"
assert len(sd) == len(fs)
assert norm(sd.keys()) == norm(fs.keys())
assert fs.getvalue("nonexistent field", "default") == "default"
verify(len(expect) == len(fcd))
verify(norm(expect.keys()) == norm(fcd.keys()))
verify(norm(expect.values()) == norm(fcd.values()))
verify(norm(expect.items()) == norm(fcd.items()))
verify(fcd.get("nonexistent field", "default") == "default")
verify(len(sd) == len(fs))
verify(norm(sd.keys()) == norm(fs.keys()))
verify(fs.getvalue("nonexistent field", "default") == "default")
# test individual fields
for key in expect.keys():
expect_val = expect[key]
assert fcd.has_key(key)
assert norm(fcd[key]) == norm(expect[key])
assert fcd.get(key, "default") == fcd[key]
assert fs.has_key(key)
verify(fcd.has_key(key))
verify(norm(fcd[key]) == norm(expect[key]))
verify(fcd.get(key, "default") == fcd[key])
verify(fs.has_key(key))
if len(expect_val) > 1:
single_value = 0
else:
@ -149,28 +150,28 @@ def main():
try:
val = sd[key]
except IndexError:
assert not single_value
assert fs.getvalue(key) == expect_val
verify(not single_value)
verify(fs.getvalue(key) == expect_val)
else:
assert single_value
assert val == expect_val[0]
assert fs.getvalue(key) == expect_val[0]
assert norm(sd.getlist(key)) == norm(expect_val)
verify(single_value)
verify(val == expect_val[0])
verify(fs.getvalue(key) == expect_val[0])
verify(norm(sd.getlist(key)) == norm(expect_val))
if single_value:
assert norm(sd.values()) == \
first_elts(norm(expect.values()))
assert norm(sd.items()) == \
first_second_elts(norm(expect.items()))
verify(norm(sd.values()) == \
first_elts(norm(expect.values())))
verify(norm(sd.items()) == \
first_second_elts(norm(expect.items())))
# Test the weird FormContentDict classes
env = {'QUERY_STRING': "x=1&y=2.0&z=2-3.%2b0&1=1abc"}
expect = {'x': 1, 'y': 2.0, 'z': '2-3.+0', '1': '1abc'}
d = cgi.InterpFormContentDict(env)
for k, v in expect.items():
assert d[k] == v
verify(d[k] == v)
for k, v in d.items():
assert expect[k] == v
assert norm(expect.values()) == norm(d.values())
verify(expect[k] == v)
verify(norm(expect.values()) == norm(d.values()))
print "Testing log"
cgi.initlog()

View File

@ -3,7 +3,7 @@
Roger E. Masse
"""
import cl
from test_support import verbose
from test_support import verify, verbose
clattrs = ['ADDED_ALGORITHM_ERROR', 'ALAW', 'ALGORITHM_ID',
'ALGORITHM_VERSION', 'AUDIO', 'AWARE_ERROR', 'AWARE_MPEG_AUDIO',

View File

@ -3,7 +3,7 @@
Roger E. Masse
"""
import cmath
from test_support import verbose
from test_support import verify, verbose
testdict = {'acos' : 1.0,
'acosh' : 1.0,

View File

@ -1,4 +1,4 @@
from test_support import verbose, TestFailed
from test_support import verify, verbose, TestFailed
if verbose:
print 'Running test on duplicate arguments'

View File

@ -16,15 +16,15 @@ for data, dict in cases:
print str(C)
for k, v in dict.items():
print ' ', k, repr( C[k].value ), repr(v)
assert C[k].value == v
verify(C[k].value == v)
print C[k]
C = Cookie.SimpleCookie()
C.load('Customer="WILE_E_COYOTE"; Version=1; Path=/acme')
assert C['Customer'].value == 'WILE_E_COYOTE'
assert C['Customer']['version'] == '1'
assert C['Customer']['path'] == '/acme'
verify(C['Customer'].value == 'WILE_E_COYOTE')
verify(C['Customer']['version'] == '1')
verify(C['Customer']['path'] == '/acme')
print C.output(['path'])
print C.js_output()
@ -33,6 +33,6 @@ print C.js_output(['path'])
# Try cookie with quoted meta-data
C = Cookie.SimpleCookie()
C.load('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"')
assert C['Customer'].value == 'WILE_E_COYOTE'
assert C['Customer']['version'] == '1'
assert C['Customer']['path'] == '/acme'
verify(C['Customer'].value == 'WILE_E_COYOTE')
verify(C['Customer']['version'] == '1')
verify(C['Customer']['path'] == '/acme')

View File

@ -3,7 +3,7 @@
Roger E. Masse
"""
from test_support import verbose
from test_support import verify, verbose
import crypt
c = crypt.crypt('mypassword', 'ab')

View File

@ -4,7 +4,7 @@
"""
import dbm
from dbm import error
from test_support import verbose
from test_support import verify, verbose
filename = '/tmp/delete_me'

View File

@ -4,7 +4,7 @@
"""
import dl
from test_support import verbose,TestSkipped
from test_support import verify, verbose,TestSkipped
sharedlibs = [
('/usr/lib/libc.so', 'getpid'),

View File

@ -4,7 +4,7 @@
"""
import errno
from test_support import verbose
from test_support import verify, verbose
errors = ['E2BIG', 'EACCES', 'EADDRINUSE', 'EADDRNOTAVAIL', 'EADV',
'EAFNOSUPPORT', 'EAGAIN', 'EALREADY', 'EBADE', 'EBADF',

View File

@ -1,3 +1,4 @@
from test_support import verify, verbose
from UserList import UserList
from test_support import TestFailed
import string
@ -79,11 +80,11 @@ g(*Nothing())
# make sure the function call doesn't stomp on the dictionary?
d = {'a': 1, 'b': 2, 'c': 3}
d2 = d.copy()
assert d == d2
verify(d == d2)
g(1, d=4, **d)
print d
print d2
assert d == d2, "function call modified dictionary"
verify(d == d2, "function call modified dictionary")
# what about willful misconduct?
def saboteur(**kw):
@ -91,7 +92,7 @@ def saboteur(**kw):
return kw
d = {}
kw = saboteur(a=1, **d)
assert d == {}
verify(d == {})
# break the cycle
del kw['x']

View File

@ -6,7 +6,7 @@ import struct
import fcntl
import FCNTL
import os, sys
from test_support import verbose, TESTFN
from test_support import verify, verbose, TESTFN
filename = TESTFN

View File

@ -1,6 +1,6 @@
import os
from test_support import TESTFN
from test_support import verify, TESTFN
from UserList import UserList
# verify writelines with instance sequence
@ -11,7 +11,7 @@ f.close()
f = open(TESTFN, 'rb')
buf = f.read()
f.close()
assert buf == '12'
verify(buf == '12')
# verify writelines with integers
f = open(TESTFN, 'wb')

View File

@ -12,7 +12,7 @@ That's OK, fork() is a grotesque hack anyway. ;-) [cjh]
"""
import os, sys, time, thread
from test_support import TestSkipped
from test_support import verify, verbose, TestSkipped
try:
if os.uname()[0] == "BeOS":
@ -51,7 +51,7 @@ def main():
a = alive.keys()
a.sort()
assert a == range(NUM_THREADS)
verify(a == range(NUM_THREADS))
prefork_lives = alive.copy()
@ -68,8 +68,9 @@ def main():
else:
# Parent
spid, status = os.waitpid(cpid, 0)
assert spid == cpid
assert status == 0, "cause = %d, exit = %d" % (status&0xff, status>>8)
verify(spid == cpid)
verify(status == 0,
"cause = %d, exit = %d" % (status&0xff, status>>8) )
global stop
# Tell threads to die
stop = 1

View File

@ -1,4 +1,4 @@
from test_support import verbose
from test_support import verify, verbose
import string, sys
# test string formatting operator (I am not sure if this is being tested

View File

@ -1,4 +1,4 @@
from test_support import verbose, TestFailed
from test_support import verify, verbose, TestFailed
import gc
def run_test(name, thunk):
@ -161,7 +161,7 @@ def test():
print "disabling automatic collection"
enabled = gc.isenabled()
gc.disable()
assert not gc.isenabled()
verify(not gc.isenabled() )
debug = gc.get_debug()
gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak
@ -174,7 +174,7 @@ def test():
print "restoring automatic collection"
# make sure to always test gc.enable()
gc.enable()
assert gc.isenabled()
verify(gc.isenabled())
if not enabled:
gc.disable()

View File

@ -5,7 +5,7 @@
import gdbm
from gdbm import error
from test_support import verbose, TestFailed
from test_support import verify, verbose, TestFailed
filename= '/tmp/delete_me'

View File

@ -3,7 +3,7 @@
import getopt
from getopt import GetoptError
from test_support import verbose
from test_support import verify, verbose
def expectException(teststr, expected, failure=AssertionError):
"""Executes a statement passed in teststr, and raises an exception
@ -17,22 +17,22 @@ def expectException(teststr, expected, failure=AssertionError):
if verbose:
print 'Running tests on getopt.short_has_arg'
assert getopt.short_has_arg('a', 'a:')
assert not getopt.short_has_arg('a', 'a')
verify(getopt.short_has_arg('a', 'a:'))
verify(not getopt.short_has_arg('a', 'a'))
expectException("tmp = getopt.short_has_arg('a', 'b')", GetoptError)
expectException("tmp = getopt.short_has_arg('a', '')", GetoptError)
if verbose:
print 'Running tests on getopt.long_has_args'
has_arg, option = getopt.long_has_args('abc', ['abc='])
assert has_arg
assert option == 'abc'
verify(has_arg)
verify(option == 'abc')
has_arg, option = getopt.long_has_args('abc', ['abc'])
assert not has_arg
assert option == 'abc'
verify(not has_arg)
verify(option == 'abc')
has_arg, option = getopt.long_has_args('abc', ['abcd'])
assert not has_arg
assert option == 'abcd'
verify(not has_arg)
verify(option == 'abcd')
expectException("has_arg, option = getopt.long_has_args('abc', ['def'])",
GetoptError)
expectException("has_arg, option = getopt.long_has_args('abc', [])",
@ -44,20 +44,20 @@ expectException("has_arg, option = " + \
if verbose:
print 'Running tests on getopt.do_shorts'
opts, args = getopt.do_shorts([], 'a', 'a', [])
assert opts == [('-a', '')]
assert args == []
verify(opts == [('-a', '')])
verify(args == [])
opts, args = getopt.do_shorts([], 'a1', 'a:', [])
assert opts == [('-a', '1')]
assert args == []
verify(opts == [('-a', '1')])
verify(args == [])
#opts, args = getopt.do_shorts([], 'a=1', 'a:', [])
#assert opts == [('-a', '1')]
#assert args == []
#verify(opts == [('-a', '1')])
#verify(args == [])
opts, args = getopt.do_shorts([], 'a', 'a:', ['1'])
assert opts == [('-a', '1')]
assert args == []
verify(opts == [('-a', '1')])
verify(args == [])
opts, args = getopt.do_shorts([], 'a', 'a:', ['1', '2'])
assert opts == [('-a', '1')]
assert args == ['2']
verify(opts == [('-a', '1')])
verify(args == ['2'])
expectException("opts, args = getopt.do_shorts([], 'a1', 'a', [])",
GetoptError)
expectException("opts, args = getopt.do_shorts([], 'a', 'a:', [])",
@ -66,23 +66,23 @@ expectException("opts, args = getopt.do_shorts([], 'a', 'a:', [])",
if verbose:
print 'Running tests on getopt.do_longs'
opts, args = getopt.do_longs([], 'abc', ['abc'], [])
assert opts == [('--abc', '')]
assert args == []
verify(opts == [('--abc', '')])
verify(args == [])
opts, args = getopt.do_longs([], 'abc=1', ['abc='], [])
assert opts == [('--abc', '1')]
assert args == []
verify(opts == [('--abc', '1')])
verify(args == [])
opts, args = getopt.do_longs([], 'abc=1', ['abcd='], [])
assert opts == [('--abcd', '1')]
assert args == []
verify(opts == [('--abcd', '1')])
verify(args == [])
opts, args = getopt.do_longs([], 'abc', ['ab', 'abc', 'abcd'], [])
assert opts == [('--abc', '')]
assert args == []
verify(opts == [('--abc', '')])
verify(args == [])
# Much like the preceding, except with a non-alpha character ("-") in
# option name that precedes "="; failed in
# http://sourceforge.net/bugs/?func=detailbug&bug_id=126863&group_id=5470
opts, args = getopt.do_longs([], 'foo=42', ['foo-bar', 'foo=',], [])
assert opts == [('--foo', '42')]
assert args == []
verify(opts == [('--foo', '42')])
verify(args == [])
expectException("opts, args = getopt.do_longs([], 'abc=1', ['abc'], [])",
GetoptError)
expectException("opts, args = getopt.do_longs([], 'abc', ['abc='], [])",
@ -96,11 +96,11 @@ cmdline = ['-a', '1', '-b', '--alpha=2', '--beta', '-a', '3', '-a', '',
if verbose:
print 'Running tests on getopt.getopt'
opts, args = getopt.getopt(cmdline, 'a:b', ['alpha=', 'beta'])
assert opts == [('-a', '1'), ('-b', ''), ('--alpha', '2'), ('--beta', ''),
('-a', '3'), ('-a', ''), ('--beta', '')]
verify(opts == [('-a', '1'), ('-b', ''), ('--alpha', '2'), ('--beta', ''),
('-a', '3'), ('-a', ''), ('--beta', '')] )
# Note ambiguity of ('-b', '') and ('-a', '') above. This must be
# accounted for in the code that calls getopt().
assert args == ['arg1', 'arg2']
verify(args == ['arg1', 'arg2'])
expectException(
"opts, args = getopt.getopt(cmdline, 'a:b', ['alpha', 'beta'])",

View File

@ -3,7 +3,7 @@
taken mostly from the documentation.
Roger E. Masse
"""
from test_support import verbose, TestSkipped
from test_support import verify, verbose, TestSkipped
import gl, GL, time
glattrs = ['RGBcolor', 'RGBcursor', 'RGBmode', 'RGBrange', 'RGBwritemask',

View File

@ -83,18 +83,18 @@ x = 3.1e4
print '1.1.3 String literals'
##def assert(s):
##def verify(s):
## if not s: raise TestFailed, 'see traceback'
x = ''; y = ""; assert(len(x) == 0 and x == y)
x = '\''; y = "'"; assert(len(x) == 1 and x == y and ord(x) == 39)
x = '"'; y = "\""; assert(len(x) == 1 and x == y and ord(x) == 34)
x = ''; y = ""; verify(len(x) == 0 and x == y)
x = '\''; y = "'"; verify(len(x) == 1 and x == y and ord(x) == 39)
x = '"'; y = "\""; verify(len(x) == 1 and x == y and ord(x) == 34)
x = "doesn't \"shrink\" does it"
y = 'doesn\'t "shrink" does it'
assert(len(x) == 24 and x == y)
verify(len(x) == 24 and x == y)
x = "does \"shrink\" doesn't it"
y = 'does "shrink" doesn\'t it'
assert(len(x) == 24 and x == y)
verify(len(x) == 24 and x == y)
x = """
The "quick"
brown fox
@ -102,25 +102,25 @@ jumps over
the 'lazy' dog.
"""
y = '\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n'
assert(x == y)
verify(x == y)
y = '''
The "quick"
brown fox
jumps over
the 'lazy' dog.
'''; assert(x == y)
'''; verify(x == y)
y = "\n\
The \"quick\"\n\
brown fox\n\
jumps over\n\
the 'lazy' dog.\n\
"; assert(x == y)
"; verify(x == y)
y = '\n\
The \"quick\"\n\
brown fox\n\
jumps over\n\
the \'lazy\' dog.\n\
'; assert(x == y)
'; verify(x == y)
print '1.2 Grammar'

View File

@ -4,7 +4,7 @@
"""
import grp
from test_support import verbose
from test_support import verify, verbose
groups = grp.getgrall()
if verbose:

View File

@ -18,13 +18,13 @@ data2 = """/* zlibmodule.c -- gzip-compatible data compression */
f = gzip.GzipFile(filename, 'wb') ; f.write(data1 * 50) ; f.close()
f = gzip.GzipFile(filename, 'rb') ; d = f.read() ; f.close()
assert d == data1*50
verify(d == data1*50)
# Append to the previous file
f = gzip.GzipFile(filename, 'ab') ; f.write(data2 * 15) ; f.close()
f = gzip.GzipFile(filename, 'rb') ; d = f.read() ; f.close()
assert d == (data1*50) + (data2*15)
verify(d == (data1*50) + (data2*15))
# Try .readline() with varying line lengths
@ -33,7 +33,7 @@ line_length = 0
while 1:
L = f.readline( line_length )
if L == "" and line_length != 0: break
assert len(L) <= line_length
verify(len(L) <= line_length)
line_length = (line_length + 1) % 50
f.close()

View File

@ -5,7 +5,7 @@
Roger E. Masse
"""
from test_support import verbose, unlink
from test_support import verify, verbose, unlink
import imageop, uu

View File

@ -4,7 +4,7 @@
Roger E. Masse
"""
from test_support import verbose, unlink, findfile
from test_support import verify, verbose, unlink, findfile
import imgfile, uu, os

View File

@ -1,4 +1,4 @@
from test_support import TestFailed, verbose
from test_support import verify, verbose, TestFailed
from string import join
from random import random, randint
@ -41,7 +41,7 @@ def check(ok, *args):
# The sign of the number is also random.
def getran(ndigits):
assert ndigits > 0
verify(ndigits > 0)
nbits_hi = ndigits * SHIFT
nbits_lo = nbits_hi - SHIFT + 1
answer = 0L
@ -50,13 +50,13 @@ def getran(ndigits):
while nbits < nbits_lo:
bits = (r >> 1) + 1
bits = min(bits, nbits_hi - nbits)
assert 1 <= bits <= SHIFT
verify(1 <= bits <= SHIFT)
nbits = nbits + bits
answer = answer << bits
if r & 1:
answer = answer | ((1 << bits) - 1)
r = int(random() * (SHIFT * 2))
assert nbits_lo <= nbits <= nbits_hi
verify(nbits_lo <= nbits <= nbits_hi)
if random() < 0.5:
answer = -answer
return answer

View File

@ -7,7 +7,7 @@ import xml.parsers.expat
import os.path
import sys
import traceback
from test_support import verbose
from test_support import verify, verbose
if __name__ == "__main__":
base = sys.argv[0]

View File

@ -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")

View File

@ -1,4 +1,4 @@
from test_support import verbose
from test_support import verify, verbose
import sys
import new

View File

@ -1,4 +1,4 @@
from test_support import verbose, TestFailed, TestSkipped
from test_support import verify, verbose, TestFailed, TestSkipped
import nis
print 'nis.maps()'

View File

@ -1,7 +1,7 @@
# Test to see if openpty works. (But don't worry if it isn't available.)
import os
from test_support import verbose, TestFailed, TestSkipped
from test_support import verify, verbose, TestFailed, TestSkipped
try:
if verbose:

View File

@ -3,7 +3,7 @@ import parser
import pprint
import sys
from test_support import TestFailed
from test_support import verify, TestFailed
#
# First, we test that we can generate trees from valid source fragments,

View File

@ -3,7 +3,7 @@
import sys, os, string, tempfile, traceback
from os import mkdir, rmdir # Can't test if these fail
del mkdir, rmdir
from test_support import verbose, TestFailed
from test_support import verify, verbose, TestFailed
# Helpers to create and destroy hierarchies.
@ -188,16 +188,16 @@ print dir()
t7, sub, subsub = None, None, None
import t7 as tas
print dir(tas)
assert not t7
verify(not t7)
from t7 import sub as subpar
print dir(subpar)
assert not t7 and not sub
verify(not t7 and not sub)
from t7.sub import subsub as subsubsub
print dir(subsubsub)
assert not t7 and not sub and not subsub
verify(not t7 and not sub and not subsub)
from t7.sub.subsub import spam as ham
print "t7.sub.subsub.spam =", ham
assert not t7 and not sub and not subsub
verify(not t7 and not sub and not subsub)
"""),
]

View File

@ -1,7 +1,7 @@
# Test case for the os.poll() function
import sys, os, select, random
from test_support import verbose, TestSkipped, TESTFN
from test_support import verify, verbose, TestSkipped, TESTFN
try:
select.poll
@ -55,7 +55,7 @@ def test_poll1():
raise RuntimeError, "no pipes ready for reading"
rd = random.choice(ready_readers)
buf = os.read(rd, MSG_LEN)
assert len(buf) == MSG_LEN
verify(len(buf) == MSG_LEN)
print buf
os.close(r2w[rd]) ; os.close( rd )
p.unregister( r2w[rd] )
@ -75,17 +75,17 @@ def poll_unit_tests():
p = select.poll()
p.register(FD)
r = p.poll()
assert r[0] == (FD, select.POLLNVAL)
verify(r[0] == (FD, select.POLLNVAL))
f = open(TESTFN, 'w')
fd = f.fileno()
p = select.poll()
p.register(f)
r = p.poll()
assert r[0][0] == fd
verify(r[0][0] == fd)
f.close()
r = p.poll()
assert r[0] == (fd, select.POLLNVAL)
verify(r[0] == (fd, select.POLLNVAL))
os.unlink(TESTFN)
# type error for invalid arguments

View File

@ -1,5 +1,5 @@
import pty, os, sys, string
from test_support import verbose, TestFailed, TestSkipped
from test_support import verify, verbose, TestFailed, TestSkipped
TEST_STRING_1 = "I wish to buy a fish license."
TEST_STRING_2 = "For my pet fish, Eric."

View File

@ -1,4 +1,4 @@
from test_support import verbose
from test_support import verify, verbose
import pwd
import string

View File

@ -1,7 +1,7 @@
import sys
sys.path = ['.'] + sys.path
from test_support import verbose, TestFailed
from test_support import verify, verbose, TestFailed
import re
import sys, os, string, traceback
@ -11,20 +11,20 @@ if verbose:
print 'Running tests on re.search and re.match'
try:
assert re.search('x*', 'axx').span(0) == (0, 0)
assert re.search('x*', 'axx').span() == (0, 0)
assert re.search('x+', 'axx').span(0) == (1, 3)
assert re.search('x+', 'axx').span() == (1, 3)
assert re.search('x', 'aaa') is None
verify(re.search('x*', 'axx').span(0) == (0, 0))
verify(re.search('x*', 'axx').span() == (0, 0))
verify(re.search('x+', 'axx').span(0) == (1, 3))
verify(re.search('x+', 'axx').span() == (1, 3))
verify(re.search('x', 'aaa') is None)
except:
raise TestFailed, "re.search"
try:
assert re.match('a*', 'xxx').span(0) == (0, 0)
assert re.match('a*', 'xxx').span() == (0, 0)
assert re.match('x*', 'xxxa').span(0) == (0, 3)
assert re.match('x*', 'xxxa').span() == (0, 3)
assert re.match('a+', 'xxx') is None
verify(re.match('a*', 'xxx').span(0) == (0, 0))
verify(re.match('a*', 'xxx').span() == (0, 0))
verify(re.match('x*', 'xxxa').span(0) == (0, 3))
verify(re.match('x*', 'xxxa').span() == (0, 3))
verify(re.match('a+', 'xxx') is None)
except:
raise TestFailed, "re.search"
@ -32,40 +32,40 @@ if verbose:
print 'Running tests on re.sub'
try:
assert re.sub("(?i)b+", "x", "bbbb BBBB") == 'x x'
verify(re.sub("(?i)b+", "x", "bbbb BBBB") == 'x x')
def bump_num(matchobj):
int_value = int(matchobj.group(0))
return str(int_value + 1)
assert re.sub(r'\d+', bump_num, '08.2 -2 23x99y') == '9.3 -3 24x100y'
assert re.sub(r'\d+', bump_num, '08.2 -2 23x99y', 3) == '9.3 -3 23x99y'
verify(re.sub(r'\d+', bump_num, '08.2 -2 23x99y') == '9.3 -3 24x100y')
verify(re.sub(r'\d+', bump_num, '08.2 -2 23x99y', 3) == '9.3 -3 23x99y')
assert re.sub('.', lambda m: r"\n", 'x') == '\\n'
assert re.sub('.', r"\n", 'x') == '\n'
verify(re.sub('.', lambda m: r"\n", 'x') == '\\n')
verify(re.sub('.', r"\n", 'x') == '\n')
s = r"\1\1"
assert re.sub('(.)', s, 'x') == 'xx'
assert re.sub('(.)', re.escape(s), 'x') == s
assert re.sub('(.)', lambda m: s, 'x') == s
verify(re.sub('(.)', s, 'x') == 'xx')
verify(re.sub('(.)', re.escape(s), 'x') == s)
verify(re.sub('(.)', lambda m: s, 'x') == s)
assert re.sub('(?P<a>x)', '\g<a>\g<a>', 'xx') == 'xxxx'
assert re.sub('(?P<a>x)', '\g<a>\g<1>', 'xx') == 'xxxx'
assert re.sub('(?P<unk>x)', '\g<unk>\g<unk>', 'xx') == 'xxxx'
assert re.sub('(?P<unk>x)', '\g<1>\g<1>', 'xx') == 'xxxx'
verify(re.sub('(?P<a>x)', '\g<a>\g<a>', 'xx') == 'xxxx')
verify(re.sub('(?P<a>x)', '\g<a>\g<1>', 'xx') == 'xxxx')
verify(re.sub('(?P<unk>x)', '\g<unk>\g<unk>', 'xx') == 'xxxx')
verify(re.sub('(?P<unk>x)', '\g<1>\g<1>', 'xx') == 'xxxx')
assert re.sub('a', r'\t\n\v\r\f\a\b\B\Z\a\A\w\W\s\S\d\D', 'a') == '\t\n\v\r\f\a\b\\B\\Z\a\\A\\w\\W\\s\\S\\d\\D'
assert re.sub('a', '\t\n\v\r\f\a', 'a') == '\t\n\v\r\f\a'
assert re.sub('a', '\t\n\v\r\f\a', 'a') == (chr(9)+chr(10)+chr(11)+chr(13)+chr(12)+chr(7))
verify(re.sub('a', r'\t\n\v\r\f\a\b\B\Z\a\A\w\W\s\S\d\D', 'a') == '\t\n\v\r\f\a\b\\B\\Z\a\\A\\w\\W\\s\\S\\d\\D')
verify(re.sub('a', '\t\n\v\r\f\a', 'a') == '\t\n\v\r\f\a')
verify(re.sub('a', '\t\n\v\r\f\a', 'a') == (chr(9)+chr(10)+chr(11)+chr(13)+chr(12)+chr(7)))
assert re.sub('^\s*', 'X', 'test') == 'Xtest'
verify(re.sub('^\s*', 'X', 'test') == 'Xtest')
except AssertionError:
raise TestFailed, "re.sub"
try:
assert re.sub('a', 'b', 'aaaaa') == 'bbbbb'
assert re.sub('a', 'b', 'aaaaa', 1) == 'baaaa'
verify(re.sub('a', 'b', 'aaaaa') == 'bbbbb')
verify(re.sub('a', 'b', 'aaaaa', 1) == 'baaaa')
except AssertionError:
raise TestFailed, "qualified re.sub"
@ -132,11 +132,11 @@ if verbose:
print 'Running tests on re.subn'
try:
assert re.subn("(?i)b+", "x", "bbbb BBBB") == ('x x', 2)
assert re.subn("b+", "x", "bbbb BBBB") == ('x BBBB', 1)
assert re.subn("b+", "x", "xyz") == ('xyz', 0)
assert re.subn("b*", "x", "xyz") == ('xxxyxzx', 4)
assert re.subn("b*", "x", "xyz", 2) == ('xxxyz', 2)
verify(re.subn("(?i)b+", "x", "bbbb BBBB") == ('x x', 2))
verify(re.subn("b+", "x", "bbbb BBBB") == ('x BBBB', 1))
verify(re.subn("b+", "x", "xyz") == ('xyz', 0))
verify(re.subn("b*", "x", "xyz") == ('xxxyxzx', 4))
verify(re.subn("b*", "x", "xyz", 2) == ('xxxyz', 2))
except AssertionError:
raise TestFailed, "re.subn"
@ -144,24 +144,24 @@ if verbose:
print 'Running tests on re.split'
try:
assert re.split(":", ":a:b::c") == ['', 'a', 'b', '', 'c']
assert re.split(":*", ":a:b::c") == ['', 'a', 'b', 'c']
assert re.split("(:*)", ":a:b::c") == ['', ':', 'a', ':', 'b', '::', 'c']
assert re.split("(?::*)", ":a:b::c") == ['', 'a', 'b', 'c']
assert re.split("(:)*", ":a:b::c") == ['', ':', 'a', ':', 'b', ':', 'c']
assert re.split("([b:]+)", ":a:b::c") == ['', ':', 'a', ':b::', 'c']
assert re.split("(b)|(:+)", ":a:b::c") == \
['', None, ':', 'a', None, ':', '', 'b', None, '', None, '::', 'c']
assert re.split("(?:b)|(?::+)", ":a:b::c") == ['', 'a', '', '', 'c']
verify(re.split(":", ":a:b::c") == ['', 'a', 'b', '', 'c'])
verify(re.split(":*", ":a:b::c") == ['', 'a', 'b', 'c'])
verify(re.split("(:*)", ":a:b::c") == ['', ':', 'a', ':', 'b', '::', 'c'])
verify(re.split("(?::*)", ":a:b::c") == ['', 'a', 'b', 'c'])
verify(re.split("(:)*", ":a:b::c") == ['', ':', 'a', ':', 'b', ':', 'c'])
verify(re.split("([b:]+)", ":a:b::c") == ['', ':', 'a', ':b::', 'c'])
verify(re.split("(b)|(:+)", ":a:b::c") == \
['', None, ':', 'a', None, ':', '', 'b', None, '', None, '::', 'c'] )
verify(re.split("(?:b)|(?::+)", ":a:b::c") == ['', 'a', '', '', 'c'])
except AssertionError:
raise TestFailed, "re.split"
try:
assert re.split(":", ":a:b::c", 2) == ['', 'a', 'b::c']
assert re.split(':', 'a:b:c:d', 2) == ['a', 'b', 'c:d']
verify(re.split(":", ":a:b::c", 2) == ['', 'a', 'b::c'])
verify(re.split(':', 'a:b:c:d', 2) == ['a', 'b', 'c:d'])
assert re.split("(:)", ":a:b::c", 2) == ['', ':', 'a', ':', 'b::c']
assert re.split("(:*)", ":a:b::c", 2) == ['', ':', 'a', ':', 'b::c']
verify(re.split("(:)", ":a:b::c", 2) == ['', ':', 'a', ':', 'b::c'])
verify(re.split("(:*)", ":a:b::c", 2) == ['', ':', 'a', ':', 'b::c'])
except AssertionError:
raise TestFailed, "qualified re.split"
@ -169,12 +169,12 @@ if verbose:
print "Running tests on re.findall"
try:
assert re.findall(":+", "abc") == []
assert re.findall(":+", "a:b::c:::d") == [":", "::", ":::"]
assert re.findall("(:+)", "a:b::c:::d") == [":", "::", ":::"]
assert re.findall("(:)(:*)", "a:b::c:::d") == [(":", ""),
verify(re.findall(":+", "abc") == [])
verify(re.findall(":+", "a:b::c:::d") == [":", "::", ":::"])
verify(re.findall("(:+)", "a:b::c:::d") == [":", "::", ":::"])
verify(re.findall("(:)(:*)", "a:b::c:::d") == [(":", ""),
(":", ":"),
(":", "::")]
(":", "::")] )
except AssertionError:
raise TestFailed, "re.findall"
@ -183,29 +183,31 @@ if verbose:
try:
# No groups at all
m = re.match('a', 'a') ; assert m.groups() == ()
m = re.match('a', 'a') ; verify(m.groups() == ())
# A single group
m = re.match('(a)', 'a') ; assert m.groups() == ('a',)
m = re.match('(a)', 'a') ; verify(m.groups() == ('a',))
pat = re.compile('((a)|(b))(c)?')
assert pat.match('a').groups() == ('a', 'a', None, None)
assert pat.match('b').groups() == ('b', None, 'b', None)
assert pat.match('ac').groups() == ('a', 'a', None, 'c')
assert pat.match('bc').groups() == ('b', None, 'b', 'c')
assert pat.match('bc').groups("") == ('b', "", 'b', 'c')
verify(pat.match('a').groups() == ('a', 'a', None, None))
verify(pat.match('b').groups() == ('b', None, 'b', None))
verify(pat.match('ac').groups() == ('a', 'a', None, 'c'))
verify(pat.match('bc').groups() == ('b', None, 'b', 'c'))
verify(pat.match('bc').groups("") == ('b', "", 'b', 'c'))
except AssertionError:
raise TestFailed, "match .groups() method"
try:
# A single group
m = re.match('(a)', 'a')
assert m.group(0) == 'a' ; assert m.group(0) == 'a'
assert m.group(1) == 'a' ; assert m.group(1, 1) == ('a', 'a')
verify(m.group(0) == 'a')
verify(m.group(0) == 'a')
verify(m.group(1) == 'a')
verify(m.group(1, 1) == ('a', 'a'))
pat = re.compile('(?:(?P<a1>a)|(?P<b2>b))(?P<c3>c)?')
assert pat.match('a').group(1, 2, 3) == ('a', None, None)
assert pat.match('b').group('a1', 'b2', 'c3') == (None, 'b', None)
assert pat.match('ac').group(1, 'b2', 3) == ('a', None, 'c')
verify(pat.match('a').group(1, 2, 3) == ('a', None, None))
verify(pat.match('b').group('a1', 'b2', 'c3') == (None, 'b', None))
verify(pat.match('ac').group(1, 'b2', 3) == ('a', None, 'c'))
except AssertionError:
raise TestFailed, "match .group() method"
@ -216,12 +218,12 @@ try:
p=""
for i in range(0, 256):
p = p + chr(i)
assert re.match(re.escape(chr(i)), chr(i)) is not None
assert re.match(re.escape(chr(i)), chr(i)).span() == (0,1)
verify(re.match(re.escape(chr(i)), chr(i)) is not None)
verify(re.match(re.escape(chr(i)), chr(i)).span() == (0,1))
pat=re.compile( re.escape(p) )
assert pat.match(p) is not None
assert pat.match(p).span() == (0,256)
verify(pat.match(p) is not None)
verify(pat.match(p).span() == (0,256))
except AssertionError:
raise TestFailed, "re.escape"
@ -235,11 +237,11 @@ s = pickle.dumps(pat)
pat = pickle.loads(s)
try:
assert re.I == re.IGNORECASE
assert re.L == re.LOCALE
assert re.M == re.MULTILINE
assert re.S == re.DOTALL
assert re.X == re.VERBOSE
verify(re.I == re.IGNORECASE)
verify(re.L == re.LOCALE)
verify(re.M == re.MULTILINE)
verify(re.S == re.DOTALL)
verify(re.X == re.VERBOSE)
except AssertionError:
raise TestFailed, 're module constants'
@ -255,7 +257,7 @@ if verbose:
# Try nasty case that overflows the straightforward recursive
# implementation of repeated groups.
try:
assert re.match('(x)*', 50000*'x').span() == (0, 50000)
verify(re.match('(x)*', 50000*'x').span() == (0, 50000))
except RuntimeError, v:
print v

View File

@ -1,4 +1,4 @@
from test_support import verbose
from test_support import verify, verbose
import warnings
warnings.filterwarnings("ignore", "the regex module is deprecated",
DeprecationWarning, __name__)

View File

@ -1,4 +1,4 @@
from test_support import verbose
from test_support import verify, verbose
import rfc822, sys
try:
from cStringIO import StringIO

View File

@ -2,7 +2,7 @@
import rgbimg, os, uu
from test_support import verbose, unlink, findfile
from test_support import verify, verbose, unlink, findfile
class error(Exception):
pass

View File

@ -12,7 +12,7 @@ from xml.sax.saxutils import XMLGenerator, escape, XMLFilterBase
from xml.sax.expatreader import create_parser
from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl
from cStringIO import StringIO
from test_support import verbose, TestFailed, findfile
from test_support import verify, verbose, TestFailed, findfile
# ===== Utilities

View File

@ -1,5 +1,5 @@
# Testing select module
from test_support import verbose
from test_support import verify, verbose
import select
import os

View File

@ -1,5 +1,5 @@
# Test the signal module
from test_support import verbose, TestSkipped
from test_support import verify, verbose, TestSkipped
import signal
import os
import sys

View File

@ -8,7 +8,7 @@
# sktobj.shutdown()
from test_support import verbose, TestFailed
from test_support import verify, verbose, TestFailed
import socket
import os
import time

View File

@ -6,7 +6,7 @@
import sys
sys.path=['.']+sys.path
from test_support import verbose, TestFailed
from test_support import verify, verbose, TestFailed
import sre
import sys, os, string, traceback

View File

@ -3,7 +3,7 @@
# Sanity checker for time.strftime
import time, calendar, sys, string, os, re
from test_support import verbose
from test_support import verify, verbose
def main():
global verbose

View File

@ -1,4 +1,4 @@
from test_support import verbose, TestSkipped
from test_support import verify, verbose, TestSkipped
import string_tests
import string, sys

View File

@ -1,4 +1,4 @@
from test_support import verbose
from test_support import verify, verbose
import strop, sys
def test(name, input, output, *args):

View File

@ -1,4 +1,4 @@
from test_support import verbose, findfile, TestFailed
from test_support import verify, verbose, findfile, TestFailed
import sunaudiodev
import os

View File

@ -71,3 +71,15 @@ def findfile(file, here=__file__):
fn = os.path.join(dn, file)
if os.path.exists(fn): return fn
return file
def verify(condition, reason='test failed'):
""" Verify that condition is true. If not, raise an
AssertionError.
The optinal argument reason can be given to provide
a better error text.
"""
if not condition:
raise AssertionError,reason

View File

@ -2,7 +2,7 @@
# Create a bunch of threads, let each do some work, wait until all are done
from test_support import verbose
from test_support import verify, verbose
import random
import thread
import time

View File

@ -1,4 +1,4 @@
from test_support import verbose
from test_support import verify, verbose
import timing
r = range(100000)

View File

@ -1,4 +1,4 @@
from test_support import verbose, findfile
from test_support import verify, verbose, findfile
import tokenize, os, sys
if verbose:

View File

@ -5,6 +5,8 @@ Written by Bill Tutt.
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
"""#"
from test_support import verify, verbose
print 'Testing General Unicode Character Name, and case insensitivity...',
# General and case insensitivity test:
@ -34,15 +36,15 @@ s = u"\N{LATIN CAPITAL LETTER T}" \
u"\N{LATIN SMALL LETTER E}" \
u"\N{LATIN SMALL LETTER P}" \
u"\N{FULL STOP}"
assert s == u"The rEd fOx ate the sheep.", s
verify(s == u"The rEd fOx ate the sheep.", s)
print "done."
# misc. symbol testing
print "Testing misc. symbols for unicode character name expansion....",
assert u"\N{PILCROW SIGN}" == u"\u00b6"
assert u"\N{REPLACEMENT CHARACTER}" == u"\uFFFD"
assert u"\N{HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK}" == u"\uFF9F"
assert u"\N{FULLWIDTH LATIN SMALL LETTER A}" == u"\uFF41"
verify(u"\N{PILCROW SIGN}" == u"\u00b6")
verify(u"\N{REPLACEMENT CHARACTER}" == u"\uFFFD")
verify(u"\N{HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK}" == u"\uFF9F")
verify(u"\N{FULLWIDTH LATIN SMALL LETTER A}" == u"\uFF41")
print "done."

View File

@ -4,8 +4,8 @@ Written by Marc-Andre Lemburg (mal@lemburg.com).
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
"""
from test_support import verbose
"""#"
from test_support import verify, verbose
import sys
def test(method, input, output, *args):
@ -173,15 +173,15 @@ if 0:
# Comparisons:
print 'Testing Unicode comparisons...',
assert u'abc' == 'abc'
assert 'abc' == u'abc'
assert u'abc' == u'abc'
assert u'abcd' > 'abc'
assert 'abcd' > u'abc'
assert u'abcd' > u'abc'
assert u'abc' < 'abcd'
assert 'abc' < u'abcd'
assert u'abc' < u'abcd'
verify(u'abc' == 'abc')
verify('abc' == u'abc')
verify(u'abc' == u'abc')
verify(u'abcd' > 'abc')
verify('abcd' > u'abc')
verify(u'abcd' > u'abc')
verify(u'abc' < 'abcd')
verify('abc' < u'abcd')
verify(u'abc' < u'abcd')
print 'done.'
if 0:
@ -189,13 +189,13 @@ if 0:
print 'Testing UTF-16 code point order comparisons...',
#No surrogates, no fixup required.
assert u'\u0061' < u'\u20ac'
verify(u'\u0061' < u'\u20ac')
# Non surrogate below surrogate value, no fixup required
assert u'\u0061' < u'\ud800\udc02'
verify(u'\u0061' < u'\ud800\udc02')
# Non surrogate above surrogate value, fixup required
def test_lecmp(s, s2):
assert s < s2 , "comparison failed on %s < %s" % (s, s2)
verify(s < s2 , "comparison failed on %s < %s" % (s, s2))
def test_fixup(s):
s2 = u'\ud800\udc01'
@ -235,7 +235,7 @@ if 0:
test_fixup(u'\uff61')
# Surrogates on both sides, no fixup required
assert u'\ud800\udc02' < u'\ud84d\udc56'
verify(u'\ud800\udc02' < u'\ud84d\udc56')
print 'done.'
test('ljust', u'abc', u'abc ', 10)
@ -306,78 +306,78 @@ test('translate', u"abababc", u'iiix', {ord('a'):None, ord('b'):ord('i'), ord('c
# Contains:
print 'Testing Unicode contains method...',
assert ('a' in u'abdb') == 1
assert ('a' in u'bdab') == 1
assert ('a' in u'bdaba') == 1
assert ('a' in u'bdba') == 1
assert ('a' in u'bdba') == 1
assert (u'a' in u'bdba') == 1
assert (u'a' in u'bdb') == 0
assert (u'a' in 'bdb') == 0
assert (u'a' in 'bdba') == 1
assert (u'a' in ('a',1,None)) == 1
assert (u'a' in (1,None,'a')) == 1
assert (u'a' in (1,None,u'a')) == 1
assert ('a' in ('a',1,None)) == 1
assert ('a' in (1,None,'a')) == 1
assert ('a' in (1,None,u'a')) == 1
assert ('a' in ('x',1,u'y')) == 0
assert ('a' in ('x',1,None)) == 0
verify(('a' in u'abdb') == 1)
verify(('a' in u'bdab') == 1)
verify(('a' in u'bdaba') == 1)
verify(('a' in u'bdba') == 1)
verify(('a' in u'bdba') == 1)
verify((u'a' in u'bdba') == 1)
verify((u'a' in u'bdb') == 0)
verify((u'a' in 'bdb') == 0)
verify((u'a' in 'bdba') == 1)
verify((u'a' in ('a',1,None)) == 1)
verify((u'a' in (1,None,'a')) == 1)
verify((u'a' in (1,None,u'a')) == 1)
verify(('a' in ('a',1,None)) == 1)
verify(('a' in (1,None,'a')) == 1)
verify(('a' in (1,None,u'a')) == 1)
verify(('a' in ('x',1,u'y')) == 0)
verify(('a' in ('x',1,None)) == 0)
print 'done.'
# Formatting:
print 'Testing Unicode formatting strings...',
assert u"%s, %s" % (u"abc", "abc") == u'abc, abc'
assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", 1, 2, 3) == u'abc, abc, 1, 2.000000, 3.00'
assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", 1, -2, 3) == u'abc, abc, 1, -2.000000, 3.00'
assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.5) == u'abc, abc, -1, -2.000000, 3.50'
assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.57) == u'abc, abc, -1, -2.000000, 3.57'
assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 1003.57) == u'abc, abc, -1, -2.000000, 1003.57'
assert u"%c" % (u"a",) == u'a'
assert u"%c" % ("a",) == u'a'
assert u"%c" % (34,) == u'"'
assert u"%c" % (36,) == u'$'
verify(u"%s, %s" % (u"abc", "abc") == u'abc, abc')
verify(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", 1, 2, 3) == u'abc, abc, 1, 2.000000, 3.00')
verify(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", 1, -2, 3) == u'abc, abc, 1, -2.000000, 3.00')
verify(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.5) == u'abc, abc, -1, -2.000000, 3.50')
verify(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.57) == u'abc, abc, -1, -2.000000, 3.57')
verify(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 1003.57) == u'abc, abc, -1, -2.000000, 1003.57')
verify(u"%c" % (u"a",) == u'a')
verify(u"%c" % ("a",) == u'a')
verify(u"%c" % (34,) == u'"')
verify(u"%c" % (36,) == u'$')
value = u"%r, %r" % (u"abc", "abc")
if value != u"u'abc', 'abc'":
print '*** formatting failed for "%s"' % 'u"%r, %r" % (u"abc", "abc")'
assert u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"} == u'abc, def'
verify(u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"} == u'abc, def')
try:
value = u"%(x)s, %(ä)s" % {'x':u"abc", u'ä'.encode('utf-8'):"def"}
except KeyError:
print '*** formatting failed for "%s"' % "u'abc, def'"
else:
assert value == u'abc, def'
verify(value == u'abc, def')
# formatting jobs delegated from the string implementation:
assert '...%(foo)s...' % {'foo':u"abc"} == u'...abc...'
assert '...%(foo)s...' % {'foo':"abc"} == '...abc...'
assert '...%(foo)s...' % {u'foo':"abc"} == '...abc...'
assert '...%(foo)s...' % {u'foo':u"abc"} == u'...abc...'
assert '...%(foo)s...' % {u'foo':u"abc",'def':123} == u'...abc...'
assert '...%(foo)s...' % {u'foo':u"abc",u'def':123} == u'...abc...'
assert '...%s...%s...%s...%s...' % (1,2,3,u"abc") == u'...1...2...3...abc...'
assert '...%%...%%s...%s...%s...%s...%s...' % (1,2,3,u"abc") == u'...%...%s...1...2...3...abc...'
assert '...%s...' % u"abc" == u'...abc...'
verify('...%(foo)s...' % {'foo':u"abc"} == u'...abc...')
verify('...%(foo)s...' % {'foo':"abc"} == '...abc...')
verify('...%(foo)s...' % {u'foo':"abc"} == '...abc...')
verify('...%(foo)s...' % {u'foo':u"abc"} == u'...abc...')
verify('...%(foo)s...' % {u'foo':u"abc",'def':123} == u'...abc...')
verify('...%(foo)s...' % {u'foo':u"abc",u'def':123} == u'...abc...')
verify('...%s...%s...%s...%s...' % (1,2,3,u"abc") == u'...1...2...3...abc...')
verify('...%%...%%s...%s...%s...%s...%s...' % (1,2,3,u"abc") == u'...%...%s...1...2...3...abc...')
verify('...%s...' % u"abc" == u'...abc...')
print 'done.'
# Test builtin codecs
print 'Testing builtin codecs...',
# UTF-8 specific encoding tests:
assert u'\u20ac'.encode('utf-8') == \
''.join((chr(0xe2), chr(0x82), chr(0xac)))
assert u'\ud800\udc02'.encode('utf-8') == \
''.join((chr(0xf0), chr(0x90), chr(0x80), chr(0x82)))
assert u'\ud84d\udc56'.encode('utf-8') == \
''.join((chr(0xf0), chr(0xa3), chr(0x91), chr(0x96)))
verify(u'\u20ac'.encode('utf-8') == \
''.join((chr(0xe2), chr(0x82), chr(0xac))) )
verify(u'\ud800\udc02'.encode('utf-8') == \
''.join((chr(0xf0), chr(0x90), chr(0x80), chr(0x82))) )
verify(u'\ud84d\udc56'.encode('utf-8') == \
''.join((chr(0xf0), chr(0xa3), chr(0x91), chr(0x96))) )
# UTF-8 specific decoding tests
assert unicode(''.join((chr(0xf0), chr(0xa3), chr(0x91), chr(0x96))),
'utf-8') == u'\ud84d\udc56'
assert unicode(''.join((chr(0xf0), chr(0x90), chr(0x80), chr(0x82))),
'utf-8') == u'\ud800\udc02'
assert unicode(''.join((chr(0xe2), chr(0x82), chr(0xac))),
'utf-8') == u'\u20ac'
verify(unicode(''.join((chr(0xf0), chr(0xa3), chr(0x91), chr(0x96))),
'utf-8') == u'\ud84d\udc56' )
verify(unicode(''.join((chr(0xf0), chr(0x90), chr(0x80), chr(0x82))),
'utf-8') == u'\ud800\udc02' )
verify(unicode(''.join((chr(0xe2), chr(0x82), chr(0xac))),
'utf-8') == u'\u20ac' )
# Other possible utf-8 test cases:
# * strict decoding testing for all of the
@ -385,10 +385,10 @@ assert unicode(''.join((chr(0xe2), chr(0x82), chr(0xac))),
assert unicode('hello','ascii') == u'hello'
assert unicode('hello','utf-8') == u'hello'
assert unicode('hello','utf8') == u'hello'
assert unicode('hello','latin-1') == u'hello'
verify(unicode('hello','ascii') == u'hello')
verify(unicode('hello','utf-8') == u'hello')
verify(unicode('hello','utf8') == u'hello')
verify(unicode('hello','latin-1') == u'hello')
class String:
x = ''
@ -398,12 +398,12 @@ class String:
o = String()
o.x = 'abc'
assert unicode(o) == u'abc'
assert str(o) == 'abc'
verify(unicode(o) == u'abc')
verify(str(o) == 'abc')
o.x = u'abc'
assert unicode(o) == u'abc'
assert str(o) == 'abc'
verify(unicode(o) == u'abc')
verify(str(o) == 'abc')
try:
u'Andr\202 x'.encode('ascii')
@ -412,8 +412,8 @@ except ValueError:
pass
else:
raise AssertionError, "u'Andr\202'.encode('ascii') failed to raise an exception"
assert u'Andr\202 x'.encode('ascii','ignore') == "Andr x"
assert u'Andr\202 x'.encode('ascii','replace') == "Andr? x"
verify(u'Andr\202 x'.encode('ascii','ignore') == "Andr x")
verify(u'Andr\202 x'.encode('ascii','replace') == "Andr? x")
try:
unicode('Andr\202 x','ascii')
@ -422,27 +422,27 @@ except ValueError:
pass
else:
raise AssertionError, "unicode('Andr\202') failed to raise an exception"
assert unicode('Andr\202 x','ascii','ignore') == u"Andr x"
assert unicode('Andr\202 x','ascii','replace') == u'Andr\uFFFD x'
verify(unicode('Andr\202 x','ascii','ignore') == u"Andr x")
verify(unicode('Andr\202 x','ascii','replace') == u'Andr\uFFFD x')
assert u'hello'.encode('ascii') == 'hello'
assert u'hello'.encode('utf-8') == 'hello'
assert u'hello'.encode('utf8') == 'hello'
assert u'hello'.encode('utf-16-le') == 'h\000e\000l\000l\000o\000'
assert u'hello'.encode('utf-16-be') == '\000h\000e\000l\000l\000o'
assert u'hello'.encode('latin-1') == 'hello'
verify(u'hello'.encode('ascii') == 'hello')
verify(u'hello'.encode('utf-8') == 'hello')
verify(u'hello'.encode('utf8') == 'hello')
verify(u'hello'.encode('utf-16-le') == 'h\000e\000l\000l\000o\000')
verify(u'hello'.encode('utf-16-be') == '\000h\000e\000l\000l\000o')
verify(u'hello'.encode('latin-1') == 'hello')
u = u''.join(map(unichr, range(1024)))
for encoding in ('utf-8', 'utf-16', 'utf-16-le', 'utf-16-be',
'raw_unicode_escape', 'unicode_escape', 'unicode_internal'):
assert unicode(u.encode(encoding),encoding) == u
verify(unicode(u.encode(encoding),encoding) == u)
u = u''.join(map(unichr, range(256)))
for encoding in (
'latin-1',
):
try:
assert unicode(u.encode(encoding),encoding) == u
verify(unicode(u.encode(encoding),encoding) == u)
except AssertionError:
print '*** codec "%s" failed round-trip' % encoding
except ValueError,why:
@ -453,7 +453,7 @@ for encoding in (
'ascii',
):
try:
assert unicode(u.encode(encoding),encoding) == u
verify(unicode(u.encode(encoding),encoding) == u)
except AssertionError:
print '*** codec "%s" failed round-trip' % encoding
except ValueError,why:
@ -487,7 +487,7 @@ for encoding in (
):
try:
assert unicode(s,encoding).encode(encoding) == s
verify(unicode(s,encoding).encode(encoding) == s)
except AssertionError:
print '*** codec "%s" failed round-trip' % encoding
except ValueError,why:
@ -517,7 +517,7 @@ for encoding in (
):
try:
assert unicode(s,encoding).encode(encoding) == s
verify(unicode(s,encoding).encode(encoding) == s)
except AssertionError:
print '*** codec "%s" failed round-trip' % encoding
except ValueError,why:
@ -526,9 +526,9 @@ for encoding in (
print 'done.'
print 'Testing Unicode string concatenation...',
assert (u"abc" u"def") == u"abcdef"
assert ("abc" u"def") == u"abcdef"
assert (u"abc" "def") == u"abcdef"
assert (u"abc" u"def" "ghi") == u"abcdefghi"
assert ("abc" "def" u"ghi") == u"abcdefghi"
verify((u"abc" u"def") == u"abcdef")
verify(("abc" u"def") == u"abcdef")
verify((u"abc" "def") == u"abcdef")
verify((u"abc" u"def" "ghi") == u"abcdefghi")
verify(("abc" "def" u"ghi") == u"abcdefghi")
print 'done.'

View File

@ -5,6 +5,7 @@
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
"""#"
from test_support import verify, verbose
import sha
encoding = 'utf-8'
@ -87,38 +88,38 @@ print test_unicodedata()
# Some additional checks of the API:
print 'API:',
assert unicodedata.digit(u'A',None) is None
assert unicodedata.digit(u'9') == 9
assert unicodedata.digit(u'\u215b',None) is None
assert unicodedata.digit(u'\u2468') == 9
verify(unicodedata.digit(u'A',None) is None)
verify(unicodedata.digit(u'9') == 9)
verify(unicodedata.digit(u'\u215b',None) is None)
verify(unicodedata.digit(u'\u2468') == 9)
assert unicodedata.numeric(u'A',None) is None
assert unicodedata.numeric(u'9') == 9
assert unicodedata.numeric(u'\u215b') == 0.125
assert unicodedata.numeric(u'\u2468') == 9.0
verify(unicodedata.numeric(u'A',None) is None)
verify(unicodedata.numeric(u'9') == 9)
verify(unicodedata.numeric(u'\u215b') == 0.125)
verify(unicodedata.numeric(u'\u2468') == 9.0)
assert unicodedata.decimal(u'A',None) is None
assert unicodedata.decimal(u'9') == 9
assert unicodedata.decimal(u'\u215b',None) is None
assert unicodedata.decimal(u'\u2468',None) is None
verify(unicodedata.decimal(u'A',None) is None)
verify(unicodedata.decimal(u'9') == 9)
verify(unicodedata.decimal(u'\u215b',None) is None)
verify(unicodedata.decimal(u'\u2468',None) is None)
assert unicodedata.category(u'\uFFFE') == 'Cn'
assert unicodedata.category(u'a') == 'Ll'
assert unicodedata.category(u'A') == 'Lu'
verify(unicodedata.category(u'\uFFFE') == 'Cn')
verify(unicodedata.category(u'a') == 'Ll')
verify(unicodedata.category(u'A') == 'Lu')
assert unicodedata.bidirectional(u'\uFFFE') == ''
assert unicodedata.bidirectional(u' ') == 'WS'
assert unicodedata.bidirectional(u'A') == 'L'
verify(unicodedata.bidirectional(u'\uFFFE') == '')
verify(unicodedata.bidirectional(u' ') == 'WS')
verify(unicodedata.bidirectional(u'A') == 'L')
assert unicodedata.decomposition(u'\uFFFE') == ''
assert unicodedata.decomposition(u'\u00bc') == '<fraction> 0031 2044 0034'
verify(unicodedata.decomposition(u'\uFFFE') == '')
verify(unicodedata.decomposition(u'\u00bc') == '<fraction> 0031 2044 0034')
assert unicodedata.mirrored(u'\uFFFE') == 0
assert unicodedata.mirrored(u'a') == 0
assert unicodedata.mirrored(u'\u2201') == 1
verify(unicodedata.mirrored(u'\uFFFE') == 0)
verify(unicodedata.mirrored(u'a') == 0)
verify(unicodedata.mirrored(u'\u2201') == 1)
assert unicodedata.combining(u'\uFFFE') == 0
assert unicodedata.combining(u'a') == 0
assert unicodedata.combining(u'\u20e1') == 230
verify(unicodedata.combining(u'\uFFFE') == 0)
verify(unicodedata.combining(u'a') == 0)
verify(unicodedata.combining(u'\u20e1') == 230)
print 'ok'

View File

@ -1,4 +1,5 @@
# Minimal test of the quote function
from test_support import verify, verbose
import urllib
chars = 'abcdefghijklmnopqrstuvwxyz'\
@ -11,20 +12,20 @@ chars = 'abcdefghijklmnopqrstuvwxyz'\
expected = 'abcdefghijklmnopqrstuvwxyz%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f8%f9%fa%fb%fc%fd%fe%ffABCDEFGHIJKLMNOPQRSTUVWXYZ%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d8%d9%da%db%dc%dd%de'
test = urllib.quote(chars)
assert test == expected, "urllib.quote problem"
verify(test == expected, "urllib.quote problem")
test2 = urllib.unquote(expected)
assert test2 == chars
verify(test2 == chars)
in1 = "abc/def"
out1_1 = "abc/def"
out1_2 = "abc%2fdef"
assert urllib.quote(in1) == out1_1, "urllib.quote problem"
assert urllib.quote(in1, '') == out1_2, "urllib.quote problem"
verify(urllib.quote(in1) == out1_1, "urllib.quote problem")
verify(urllib.quote(in1, '') == out1_2, "urllib.quote problem")
in2 = "abc?def"
out2_1 = "abc%3fdef"
out2_2 = "abc?def"
assert urllib.quote(in2) == out2_1, "urllib.quote problem"
assert urllib.quote(in2, '?') == out2_2, "urllib.quote problem"
verify(urllib.quote(in2) == out2_1, "urllib.quote problem")
verify(urllib.quote(in2, '?') == out2_2, "urllib.quote problem")

View File

@ -1,5 +1,6 @@
# Check every path through every method of UserDict
from test_support import verify, verbose
from UserDict import UserDict
d0 = {}
@ -20,26 +21,26 @@ uu2 = UserDict(u2)
# Test __repr__
assert str(u0) == str(d0)
assert repr(u1) == repr(d1)
assert `u2` == `d2`
verify(str(u0) == str(d0))
verify(repr(u1) == repr(d1))
verify(`u2` == `d2`)
# Test __cmp__ and __len__
all = [d0, d1, d2, u, u0, u1, u2, uu, uu0, uu1, uu2]
for a in all:
for b in all:
assert cmp(a, b) == cmp(len(a), len(b))
verify(cmp(a, b) == cmp(len(a), len(b)))
# Test __getitem__
assert u2["one"] == 1
verify(u2["one"] == 1)
try:
u1["two"]
except KeyError:
pass
else:
assert 0, "u1['two'] shouldn't exist"
verify(0, "u1['two'] shouldn't exist")
# Test __setitem__
@ -55,47 +56,47 @@ try:
except KeyError:
pass
else:
assert 0, "u3['three'] shouldn't exist"
verify(0, "u3['three'] shouldn't exist")
# Test clear
u3.clear()
assert u3 == {}
verify(u3 == {})
# Test copy()
u2a = u2.copy()
assert u2a == u2
verify(u2a == u2)
class MyUserDict(UserDict):
def display(self): print self
m2 = MyUserDict(u2)
m2a = m2.copy()
assert m2a == m2
verify(m2a == m2)
# Test keys, items, values
assert u2.keys() == d2.keys()
assert u2.items() == d2.items()
assert u2.values() == d2.values()
verify(u2.keys() == d2.keys())
verify(u2.items() == d2.items())
verify(u2.values() == d2.values())
# Test has_key
for i in u2.keys():
assert u2.has_key(i) == 1
assert u1.has_key(i) == d1.has_key(i)
assert u0.has_key(i) == d0.has_key(i)
verify(u2.has_key(i) == 1)
verify(u1.has_key(i) == d1.has_key(i))
verify(u0.has_key(i) == d0.has_key(i))
# Test update
t = UserDict()
t.update(u2)
assert t == u2
verify(t == u2)
# Test get
for i in u2.keys():
assert u2.get(i) == u2[i]
assert u1.get(i) == d1.get(i)
assert u0.get(i) == d0.get(i)
verify(u2.get(i) == u2[i])
verify(u1.get(i) == d1.get(i))
verify(u0.get(i) == d0.get(i))

View File

@ -3,7 +3,7 @@
from UserList import UserList
from test_support import TestFailed
# Use check instead of assert so -O doesn't render the
# Use check instead of verify(so -O doesn't render the)
# test useless.
def check(predicate, msg):
if not predicate:

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
import sys, string
from test_support import verbose
from test_support import verify, verbose
import string_tests
# UserString is a wrapper around the native builtin string type.
# UserString instances should behave similar to builtin string objects.

View File

@ -31,11 +31,11 @@ def WriteTestData(root_key):
# Check we wrote as many items as we thought.
nkeys, nvalues, since_mod = QueryInfoKey(key)
assert nkeys==1, "Not the correct number of sub keys"
assert nvalues==1, "Not the correct number of values"
verify(nkeys==1, "Not the correct number of sub keys")
verify(nvalues==1, "Not the correct number of values")
nkeys, nvalues, since_mod = QueryInfoKey(sub_key)
assert nkeys==0, "Not the correct number of sub keys"
assert nvalues==len(test_data), "Not the correct number of values"
verify(nkeys==0, "Not the correct number of sub keys")
verify(nvalues==len(test_data), "Not the correct number of values")
# Close this key this way...
# (but before we do, copy the key as an integer - this allows
# us to test that the key really gets closed).
@ -58,7 +58,7 @@ def WriteTestData(root_key):
def ReadTestData(root_key):
# Check we can get default value for this key.
val = QueryValue(root_key, test_key_name)
assert val=="Default value", "Registry didn't give back the correct value"
verify(val=="Default value", "Registry didn't give back the correct value")
key = OpenKey(root_key, test_key_name)
# Read the sub-keys
@ -70,21 +70,21 @@ def ReadTestData(root_key):
data = EnumValue(sub_key, index)
except EnvironmentError:
break
assert data in test_data, "Didn't read back the correct test data"
verify(data in test_data, "Didn't read back the correct test data")
index = index + 1
assert index==len(test_data), "Didn't read the correct number of items"
verify(index==len(test_data), "Didn't read the correct number of items")
# Check I can directly access each item
for value_name, value_data, value_type in test_data:
read_val, read_typ = QueryValueEx(sub_key, value_name)
assert read_val==value_data and read_typ == value_type, \
"Could not directly read the value"
verify(read_val==value_data and read_typ == value_type, \
"Could not directly read the value" )
sub_key.Close()
# Enumerate our main key.
read_val = EnumKey(key, 0)
assert read_val == "sub_key", "Read subkey value wrong"
verify(read_val == "sub_key", "Read subkey value wrong")
try:
EnumKey(key, 1)
assert 0, "Was able to get a second key when I only have one!"
verify(0, "Was able to get a second key when I only have one!")
except EnvironmentError:
pass
@ -100,14 +100,14 @@ def DeleteTestData(root_key):
DeleteValue(sub_key, value_name)
nkeys, nvalues, since_mod = QueryInfoKey(sub_key)
assert nkeys==0 and nvalues==0, "subkey not empty before delete"
verify(nkeys==0 and nvalues==0, "subkey not empty before delete")
sub_key.Close()
DeleteKey(key, "sub_key")
try:
# Shouldnt be able to delete it twice!
DeleteKey(key, "sub_key")
assert 0, "Deleting the key twice succeeded"
verify(0, "Deleting the key twice succeeded")
except EnvironmentError:
pass
key.Close()
@ -115,7 +115,7 @@ def DeleteTestData(root_key):
# Opening should now fail!
try:
key = OpenKey(root_key, test_key_name)
assert 0, "Could open the non-existent key"
verify(0, "Could open the non-existent key")
except WindowsError: # Use this error name this time
pass

View File

@ -2,7 +2,7 @@
Sjoerd Mullender
'''
from test_support import verbose
from test_support import verify, verbose
testdoc = """\
<?xml version="1.0" encoding="UTF-8" standalone='yes' ?>