mirror of https://github.com/swig/swig
Test-suite: Unify string quoting in the Python sources
This commit is contained in:
parent
c4ad3480bd
commit
fa5f519bf9
|
@ -1,21 +1,21 @@
|
|||
from argcargvtest import *
|
||||
|
||||
largs = ['hi', 'hola', 'hello']
|
||||
largs = ["hi", "hola", "hello"]
|
||||
if mainc(largs) != 3:
|
||||
raise RuntimeError("bad main typemap")
|
||||
|
||||
targs = ('hi', 'hola')
|
||||
if mainv(targs, 1) != 'hola':
|
||||
targs = ("hi", "hola")
|
||||
if mainv(targs, 1) != "hola":
|
||||
print(mainv(targs, 1))
|
||||
raise RuntimeError("bad main typemap")
|
||||
|
||||
targs = ('hi', 'hola')
|
||||
if mainv(targs, 1) != 'hola':
|
||||
targs = ("hi", "hola")
|
||||
if mainv(targs, 1) != "hola":
|
||||
raise RuntimeError("bad main typemap")
|
||||
|
||||
try:
|
||||
error = 0
|
||||
mainv('hello', 1)
|
||||
mainv("hello", 1)
|
||||
error = 1
|
||||
except TypeError:
|
||||
pass
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
from char_binary import *
|
||||
|
||||
t = Test()
|
||||
if t.strlen('hile') != 4:
|
||||
print t.strlen('hile')
|
||||
if t.strlen("hile") != 4:
|
||||
print t.strlen("hile")
|
||||
raise RuntimeError, "bad multi-arg typemap"
|
||||
if t.ustrlen('hile') != 4:
|
||||
print t.ustrlen('hile')
|
||||
if t.ustrlen("hile") != 4:
|
||||
print t.ustrlen("hile")
|
||||
raise RuntimeError, "bad multi-arg typemap"
|
||||
|
||||
if t.strlen('hil\0') != 4:
|
||||
if t.strlen("hil\0") != 4:
|
||||
raise RuntimeError, "bad multi-arg typemap"
|
||||
if t.ustrlen('hil\0') != 4:
|
||||
if t.ustrlen("hil\0") != 4:
|
||||
raise RuntimeError, "bad multi-arg typemap"
|
||||
|
||||
#
|
||||
# creating a raw char*
|
||||
#
|
||||
pc = new_pchar(5)
|
||||
pchar_setitem(pc, 0, 'h')
|
||||
pchar_setitem(pc, 1, 'o')
|
||||
pchar_setitem(pc, 2, 'l')
|
||||
pchar_setitem(pc, 3, 'a')
|
||||
pchar_setitem(pc, 0, "h")
|
||||
pchar_setitem(pc, 1, "o")
|
||||
pchar_setitem(pc, 2, "l")
|
||||
pchar_setitem(pc, 3, "a")
|
||||
pchar_setitem(pc, 4, 0)
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
def check(got, expected, expected_builtin=None):
|
||||
if got is None: # Absence of comment is equivalent to empty comment.
|
||||
got = ''
|
||||
got = ""
|
||||
|
||||
if got != expected:
|
||||
import re
|
||||
p = re.compile(r'^[+-]([^+-].*\S)?(\s+)$', re.M)
|
||||
p = re.compile(r"^[+-]([^+-].*\S)?(\s+)$", re.M)
|
||||
|
||||
def make_trailing_spaces_visible(str):
|
||||
def replace_trailing_spaces(match):
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
from cpp17_u8_char_literals import *
|
||||
|
||||
if cvar.a != 'a':
|
||||
if cvar.a != "a":
|
||||
raise RuntimeError
|
||||
|
||||
if cvar.u != 'u':
|
||||
if cvar.u != "u":
|
||||
raise RuntimeError
|
||||
|
||||
if cvar.u8 != '8':
|
||||
if cvar.u8 != "8":
|
||||
raise RuntimeError
|
||||
|
|
|
@ -170,23 +170,23 @@ def run(module_name):
|
|||
if default_args.CDA().cdefaultargs_test2() != 1:
|
||||
raise RuntimeError
|
||||
|
||||
if default_args.chartest1() != 'x':
|
||||
if default_args.chartest1() != "x":
|
||||
raise RuntimeError
|
||||
|
||||
if default_args.chartest2() != '\0':
|
||||
if default_args.chartest2() != "\0":
|
||||
raise RuntimeError
|
||||
|
||||
if default_args.chartest3() != '\1':
|
||||
if default_args.chartest3() != "\1":
|
||||
raise RuntimeError
|
||||
|
||||
if default_args.chartest4() != '\n':
|
||||
if default_args.chartest4() != "\n":
|
||||
raise RuntimeError
|
||||
|
||||
if default_args.chartest5() != 'B':
|
||||
if default_args.chartest5() != "B":
|
||||
raise RuntimeError
|
||||
|
||||
if default_args.chartest6() != 'C':
|
||||
if default_args.chartest6() != "C":
|
||||
raise RuntimeError
|
||||
|
||||
if __name__ == "__main__":
|
||||
run('default_args')
|
||||
run("default_args")
|
||||
|
|
|
@ -75,7 +75,7 @@ b = launder(a)
|
|||
try:
|
||||
b.pong()
|
||||
except MyException, e:
|
||||
if e.msg == 'foobar':
|
||||
if e.msg == "foobar":
|
||||
ok = 1
|
||||
else:
|
||||
print "Unexpected error message: %s" % str(e)
|
||||
|
|
|
@ -44,7 +44,7 @@ comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.getConnection),
|
|||
|
||||
|
||||
comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.getFirstLetter),
|
||||
r''
|
||||
r""
|
||||
)
|
||||
|
||||
comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.ClassWithNestedEnum),
|
||||
|
@ -73,7 +73,7 @@ comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.isNoSpaceValidB),
|
|||
)
|
||||
|
||||
comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.isNoSpaceValidC),
|
||||
r''
|
||||
r""
|
||||
)
|
||||
|
||||
comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.backslashA),
|
||||
|
|
|
@ -2,7 +2,7 @@ from ignore_parameter import *
|
|||
|
||||
def check(a, b):
|
||||
if a != b:
|
||||
raise RuntimeError('"%s" != "%s"' % (a, b))
|
||||
raise RuntimeError("'%s' != '%s'" % (a, b))
|
||||
|
||||
check(jaguar(200, 0), "hello")
|
||||
check(lotus("foo", 1), 101)
|
||||
|
|
|
@ -18,10 +18,10 @@ if test4("hello") != "hello-suffix":
|
|||
print test4("hello")
|
||||
raise RuntimeError
|
||||
|
||||
if test5(4) != 'xxxx':
|
||||
if test5(4) != "xxxx":
|
||||
raise RuntimeError
|
||||
|
||||
if test6(10) != 'xxxxx':
|
||||
if test6(10) != "xxxxx":
|
||||
raise RuntimeError
|
||||
|
||||
if test7() != "Hello world!":
|
||||
|
|
|
@ -15,10 +15,10 @@ if test3("hello") != u"hello-suffix":
|
|||
if test4("hello") != u"hello-suffix":
|
||||
raise RuntimeError
|
||||
|
||||
if test5(4) != u'xxxx':
|
||||
if test5(4) != u"xxxx":
|
||||
raise RuntimeError
|
||||
|
||||
if test6(10) != u'xxxxx':
|
||||
if test6(10) != u"xxxxx":
|
||||
raise RuntimeError
|
||||
|
||||
if test7() != u"Hello world!":
|
||||
|
|
|
@ -90,5 +90,5 @@ sum = ()
|
|||
for i in s:
|
||||
sum = sum + (i,)
|
||||
|
||||
if (len(sum) != 3 or (not 1 in sum) or (not 'hello' in sum) or (not (1, 2) in sum)):
|
||||
if (len(sum) != 3 or (not 1 in sum) or (not "hello" in sum) or (not (1, 2) in sum)):
|
||||
raise RuntimeError
|
||||
|
|
|
@ -19,7 +19,7 @@ if li_std_string_extra.test_const_reference(x) != x:
|
|||
|
||||
s = li_std_string_extra.string("he")
|
||||
#s += "ll"
|
||||
# s.append('o')
|
||||
# s.append("o")
|
||||
s = s + "llo"
|
||||
|
||||
if s != x:
|
||||
|
|
|
@ -91,7 +91,7 @@ if v.size() != 0:
|
|||
|
||||
|
||||
v = vecStr(["hello ", "world"])
|
||||
if v[0] != 'hello world':
|
||||
if v[0] != "hello world":
|
||||
raise RuntimeError, "bad std::string+std::vector"
|
||||
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ if ref_double(3.5) != 3.5:
|
|||
if ref_bool(True) != True:
|
||||
raise RuntimeError
|
||||
|
||||
if ref_char('x') != 'x':
|
||||
if ref_char("x") != "x":
|
||||
raise RuntimeError
|
||||
|
||||
if ref_over(0) != 0:
|
||||
|
|
|
@ -227,7 +227,7 @@ t.var_paramc = sct_paramc
|
|||
t.v_check()
|
||||
|
||||
# this value contains a '0' char!
|
||||
if def_namet != 'hola':
|
||||
if def_namet != "hola":
|
||||
print "bad namet", def_namet
|
||||
raise RuntimeError
|
||||
|
||||
|
@ -236,54 +236,54 @@ if t.var_namet != def_namet:
|
|||
print "bad namet", t.var_namet, def_namet
|
||||
raise RuntimeError
|
||||
|
||||
t.var_namet = 'hola'
|
||||
t.var_namet = "hola"
|
||||
|
||||
if t.var_namet != 'hola':
|
||||
if t.var_namet != "hola":
|
||||
print "bad namet", t.var_namet
|
||||
raise RuntimeError
|
||||
|
||||
t.var_namet = 'hol'
|
||||
t.var_namet = "hol"
|
||||
|
||||
if t.var_namet != 'hol':
|
||||
# if t.var_namet != 'hol\0\0':
|
||||
if t.var_namet != "hol":
|
||||
# if t.var_namet != "hol\0\0":
|
||||
print "bad namet", t.var_namet
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
cvar.var_char = '\0'
|
||||
if cvar.var_char != '\0':
|
||||
cvar.var_char = "\0"
|
||||
if cvar.var_char != "\0":
|
||||
raise RuntimeError, "bad char '0' case"
|
||||
|
||||
cvar.var_char = 0
|
||||
if cvar.var_char != '\0':
|
||||
if cvar.var_char != "\0":
|
||||
raise RuntimeError, "bad char '0' case"
|
||||
|
||||
cvar.var_namet = '\0'
|
||||
# if cvar.var_namet != '\0\0\0\0\0':
|
||||
if cvar.var_namet != '':
|
||||
print 'hola', '', cvar.var_namet
|
||||
cvar.var_namet = "\0"
|
||||
# if cvar.var_namet != "\0\0\0\0\0":
|
||||
if cvar.var_namet != "":
|
||||
print "hola", "", cvar.var_namet
|
||||
raise RuntimeError, "bad char '\0' case"
|
||||
|
||||
cvar.var_namet = ''
|
||||
# if cvar.var_namet != '\0\0\0\0\0':
|
||||
if cvar.var_namet != '':
|
||||
cvar.var_namet = ""
|
||||
# if cvar.var_namet != "\0\0\0\0\0":
|
||||
if cvar.var_namet != "":
|
||||
raise RuntimeError, "bad char empty case"
|
||||
|
||||
cvar.var_pchar = None
|
||||
if cvar.var_pchar != None:
|
||||
raise RuntimeError, "bad None case"
|
||||
|
||||
cvar.var_pchar = ''
|
||||
if cvar.var_pchar != '':
|
||||
print '%c' % (cvar.var_pchar[0],)
|
||||
cvar.var_pchar = ""
|
||||
if cvar.var_pchar != "":
|
||||
print "%c" % (cvar.var_pchar[0],)
|
||||
raise RuntimeError, "bad char empty case"
|
||||
|
||||
cvar.var_pcharc = None
|
||||
if cvar.var_pcharc != None:
|
||||
raise RuntimeError, "bad None case"
|
||||
|
||||
cvar.var_pcharc = ''
|
||||
if cvar.var_pcharc != '':
|
||||
cvar.var_pcharc = ""
|
||||
if cvar.var_pcharc != "":
|
||||
raise RuntimeError, "bad char empty case"
|
||||
|
||||
|
||||
|
@ -291,10 +291,10 @@ if cvar.var_pcharc != '':
|
|||
# creating a raw char*
|
||||
#
|
||||
pc = new_pchar(5)
|
||||
pchar_setitem(pc, 0, 'h')
|
||||
pchar_setitem(pc, 1, 'o')
|
||||
pchar_setitem(pc, 2, 'l')
|
||||
pchar_setitem(pc, 3, 'a')
|
||||
pchar_setitem(pc, 0, "h")
|
||||
pchar_setitem(pc, 1, "o")
|
||||
pchar_setitem(pc, 2, "l")
|
||||
pchar_setitem(pc, 3, "a")
|
||||
pchar_setitem(pc, 4, 0)
|
||||
|
||||
|
||||
|
@ -331,7 +331,7 @@ if error:
|
|||
try:
|
||||
error = 0
|
||||
a = t.var_char
|
||||
t.var_char = '23'
|
||||
t.var_char = "23"
|
||||
error = 1
|
||||
except TypeError:
|
||||
if a != t.var_char:
|
||||
|
@ -393,7 +393,7 @@ if error:
|
|||
try:
|
||||
error = 0
|
||||
a = t.var_namet
|
||||
t.var_namet = '123456'
|
||||
t.var_namet = "123456"
|
||||
error = 1
|
||||
except TypeError:
|
||||
if a != t.var_namet:
|
||||
|
@ -410,11 +410,11 @@ if t.var_namet != t2.var_namet:
|
|||
raise RuntimeError, "bad SWIGTYPE* typemap"
|
||||
|
||||
|
||||
if cvar.fixsize != 'ho\0la\0\0\0':
|
||||
if cvar.fixsize != "ho\0la\0\0\0":
|
||||
raise RuntimeError, "bad FIXSIZE typemap"
|
||||
|
||||
cvar.fixsize = 'ho'
|
||||
if cvar.fixsize != 'ho\0\0\0\0\0\0':
|
||||
cvar.fixsize = "ho"
|
||||
if cvar.fixsize != "ho\0\0\0\0\0\0":
|
||||
raise RuntimeError, "bad FIXSIZE typemap"
|
||||
|
||||
|
||||
|
@ -487,26 +487,26 @@ def checkType(t, e, val, delta):
|
|||
"""t = Test object, e = type name (e.g. ulong), val = max or min allowed value, delta = +1 for max, -1 for min"""
|
||||
error = 0
|
||||
# Set the extreme valid value for var_*
|
||||
setattr(t, 'var_' + e, val)
|
||||
setattr(t, "var_" + e, val)
|
||||
# Make sure it was set properly and works properly in the val_* and ref_* methods
|
||||
if getattr(t, 'var_' + e) != val or getattr(t, 'val_' + e)(val) != val or getattr(t, 'ref_' + e)(val) != val:
|
||||
if getattr(t, "var_" + e) != val or getattr(t, "val_" + e)(val) != val or getattr(t, "ref_" + e)(val) != val:
|
||||
error = 1
|
||||
# Make sure setting a more extreme value fails without changing the value
|
||||
try:
|
||||
a = getattr(t, 'var_' + e)
|
||||
setattr(t, 'var_' + e, val + delta)
|
||||
a = getattr(t, "var_" + e)
|
||||
setattr(t, "var_" + e, val + delta)
|
||||
error = 1
|
||||
except OverflowError:
|
||||
if a != getattr(t, 'var_' + e):
|
||||
if a != getattr(t, "var_" + e):
|
||||
error = 1
|
||||
# Make sure the val_* and ref_* methods fail with a more extreme value
|
||||
try:
|
||||
getattr(t, 'val_' + e)(val + delta)
|
||||
getattr(t, "val_" + e)(val + delta)
|
||||
error = 1
|
||||
except OverflowError:
|
||||
pass
|
||||
try:
|
||||
getattr(t, 'ref_' + e)(val + delta)
|
||||
getattr(t, "ref_" + e)(val + delta)
|
||||
error = 1
|
||||
except OverflowError:
|
||||
pass
|
||||
|
@ -518,16 +518,16 @@ def checkFull(t, e, maxval, minval):
|
|||
checkType(t, e, maxval, 1)
|
||||
checkType(t, e, minval, -1)
|
||||
|
||||
checkFull(t, 'llong', maxllong, minllong)
|
||||
checkFull(t, 'long', maxlong, minlong)
|
||||
checkFull(t, 'int', maxint, minint)
|
||||
checkFull(t, 'short', maxshort, minshort)
|
||||
checkFull(t, 'schar', maxchar, minchar)
|
||||
checkFull(t, 'ullong', maxullong, 0)
|
||||
checkFull(t, 'ulong', maxulong, 0)
|
||||
checkFull(t, 'uint', maxuint, 0)
|
||||
checkFull(t, 'ushort', maxushort, 0)
|
||||
checkFull(t, 'uchar', maxuchar, 0)
|
||||
checkFull(t, "llong", maxllong, minllong)
|
||||
checkFull(t, "long", maxlong, minlong)
|
||||
checkFull(t, "int", maxint, minint)
|
||||
checkFull(t, "short", maxshort, minshort)
|
||||
checkFull(t, "schar", maxchar, minchar)
|
||||
checkFull(t, "ullong", maxullong, 0)
|
||||
checkFull(t, "ulong", maxulong, 0)
|
||||
checkFull(t, "uint", maxuint, 0)
|
||||
checkFull(t, "ushort", maxushort, 0)
|
||||
checkFull(t, "uchar", maxuchar, 0)
|
||||
|
||||
def checkOverload(t, name, val, delta, prevval, limit):
|
||||
"""
|
||||
|
@ -556,16 +556,16 @@ def checkOverload(t, name, val, delta, prevval, limit):
|
|||
raise RuntimeError, "bad " + name + " typemap"
|
||||
|
||||
# Check that overloading works: uchar > schar > ushort > short > uint > int > ulong > long > ullong > llong
|
||||
checkOverload(t, 'uchar', maxuchar, +1, 0, maxullong)
|
||||
checkOverload(t, 'ushort', maxushort, +1, maxuchar, maxullong)
|
||||
checkOverload(t, 'uint', maxuint, +1, maxushort, maxullong)
|
||||
checkOverload(t, 'ulong', maxulong, +1, maxuint, maxullong)
|
||||
checkOverload(t, 'ullong', maxullong, +1, maxulong, maxullong)
|
||||
checkOverload(t, 'schar', minchar, -1, 0, minllong)
|
||||
checkOverload(t, 'short', minshort, -1, minchar, minllong)
|
||||
checkOverload(t, 'int', minint, -1, minshort, minllong)
|
||||
checkOverload(t, 'long', minlong, -1, minint, minllong)
|
||||
checkOverload(t, 'llong', minllong, -1, minlong, minllong)
|
||||
checkOverload(t, "uchar", maxuchar, +1, 0, maxullong)
|
||||
checkOverload(t, "ushort", maxushort, +1, maxuchar, maxullong)
|
||||
checkOverload(t, "uint", maxuint, +1, maxushort, maxullong)
|
||||
checkOverload(t, "ulong", maxulong, +1, maxuint, maxullong)
|
||||
checkOverload(t, "ullong", maxullong, +1, maxulong, maxullong)
|
||||
checkOverload(t, "schar", minchar, -1, 0, minllong)
|
||||
checkOverload(t, "short", minshort, -1, minchar, minllong)
|
||||
checkOverload(t, "int", minint, -1, minshort, minllong)
|
||||
checkOverload(t, "long", minlong, -1, minint, minllong)
|
||||
checkOverload(t, "llong", minllong, -1, minlong, minllong)
|
||||
|
||||
# Make sure that large ints can be converted to doubles properly
|
||||
if val_double(sys.maxint + 1) != float(sys.maxint + 1):
|
||||
|
|
|
@ -14,13 +14,13 @@ if len(sys.argv) >= 2 and sys.argv[1] == "benchmark":
|
|||
k = 1000000 # number of times to execute the functions
|
||||
|
||||
t = time.time()
|
||||
a = bytearray(b'hello world')
|
||||
a = bytearray(b"hello world")
|
||||
for i in range(k):
|
||||
python_pybuffer.title1(a)
|
||||
print "Time used by bytearray:", time.time() - t
|
||||
|
||||
t = time.time()
|
||||
b = 'hello world'
|
||||
b = "hello world"
|
||||
for i in range(k):
|
||||
python_pybuffer.title2(b)
|
||||
print "Time used by string:", time.time() - t
|
||||
|
@ -30,7 +30,7 @@ else:
|
|||
buf2 = bytearray(50)
|
||||
|
||||
python_pybuffer.func1(buf1)
|
||||
check(buf1 == b'a' * 10)
|
||||
check(buf1 == b"a" * 10)
|
||||
|
||||
python_pybuffer.func2(buf2)
|
||||
check(buf2.startswith(b"Hello world!\x00"))
|
||||
|
@ -43,4 +43,4 @@ else:
|
|||
|
||||
buf3 = bytearray(b"hello")
|
||||
python_pybuffer.title1(buf3)
|
||||
check(buf3 == b'Hello')
|
||||
check(buf3 == b"Hello")
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import python_strict_unicode
|
||||
|
||||
test_bytes = b'hello \x01world\x99'
|
||||
BYTES = b'BYTES'
|
||||
test_unicode = u'h\udce9llo w\u00f6rld'
|
||||
test_bytes = b"hello \x01world\x99"
|
||||
BYTES = b"BYTES"
|
||||
test_unicode = u"h\udce9llo w\u00f6rld"
|
||||
|
||||
# Test that byte string inputs and outputs work as expected
|
||||
bdbl = python_strict_unicode.double_str(test_bytes)
|
||||
|
@ -20,12 +20,12 @@ if type(bout) != type(BYTES):
|
|||
udbl = python_strict_unicode.double_wstr(test_unicode)
|
||||
if udbl != test_unicode + test_unicode:
|
||||
raise RuntimeError("Failed to double wide string")
|
||||
if type(udbl) != type(u''):
|
||||
if type(udbl) != type(u""):
|
||||
raise RuntimeError("Wrong type output for wide string")
|
||||
uout = python_strict_unicode.same_wstr(test_unicode)
|
||||
if uout != test_unicode:
|
||||
raise RuntimeError("Failed to copy wchar_t*")
|
||||
if type(uout) != type(u''):
|
||||
if type(uout) != type(u""):
|
||||
raise RuntimeError("Wrong type output for wchar_t*")
|
||||
|
||||
# Test that overloading is handled properly
|
||||
|
@ -35,9 +35,9 @@ if bovr != BYTES:
|
|||
if type(bovr) != type(BYTES):
|
||||
raise RuntimeError("Wrong type output from overload")
|
||||
uovr = python_strict_unicode.overload(test_unicode)
|
||||
if uovr != u'UNICODE':
|
||||
if uovr != u"UNICODE":
|
||||
raise RuntimeError("Failed to return unicode from overload")
|
||||
if type(uovr) != type(u''):
|
||||
if type(uovr) != type(u""):
|
||||
raise RuntimeERror("Wrong type output from overload")
|
||||
|
||||
# Test that bytes aren't accepted as wide strings and unicode isn't accepted as narrow strings
|
||||
|
|
|
@ -13,8 +13,8 @@ cvar.var_bool = createref_bool(True)
|
|||
if value_bool(cvar.var_bool) != True:
|
||||
raise RuntimeError
|
||||
|
||||
cvar.var_char = createref_char('w')
|
||||
if value_char(cvar.var_char) != 'w':
|
||||
cvar.var_char = createref_char("w")
|
||||
if value_char(cvar.var_char) != "w":
|
||||
raise RuntimeError
|
||||
|
||||
cvar.var_unsigned_char = createref_unsigned_char(10)
|
||||
|
|
|
@ -60,9 +60,9 @@ if mi[0][1] != mc[0][1]:
|
|||
|
||||
|
||||
map = {}
|
||||
map['hello'] = 1
|
||||
map['hi'] = 2
|
||||
map['3'] = 2
|
||||
map["hello"] = 1
|
||||
map["hi"] = 2
|
||||
map["3"] = 2
|
||||
|
||||
imap = std_containers.mapident(map)
|
||||
for k in map:
|
||||
|
@ -70,13 +70,13 @@ for k in map:
|
|||
raise RuntimeError, "bad map"
|
||||
|
||||
# Test __contains__ (required for 'x in y' to work)
|
||||
if not imap.__contains__('hello'):
|
||||
if not imap.__contains__("hello"):
|
||||
raise RuntimeError("hello imap.__contains__")
|
||||
if 'hello' not in imap:
|
||||
if "hello" not in imap:
|
||||
raise RuntimeError("hello not in imap")
|
||||
if imap.__contains__('oops'):
|
||||
if imap.__contains__("oops"):
|
||||
raise RuntimeError("oops imap.__contains__")
|
||||
if 'oops' in imap:
|
||||
if "oops" in imap:
|
||||
raise RuntimeError("oops in imap")
|
||||
|
||||
mapc = {}
|
||||
|
|
|
@ -15,11 +15,11 @@ lthis = long(a.this)
|
|||
# match pointer value, but deal with leading zeros on 8/16 bit systems and
|
||||
# different C++ compilers interpretation of %p
|
||||
xstr1 = "%016X" % (lthis,)
|
||||
xstr1 = str.lstrip(xstr1, '0')
|
||||
xstr1 = str.lstrip(xstr1, "0")
|
||||
xstr2 = pointer_str(a)
|
||||
xstr2 = str.replace(xstr2, "0x", "")
|
||||
xstr2 = str.replace(xstr2, "0X", "")
|
||||
xstr2 = str.lstrip(xstr2, '0')
|
||||
xstr2 = str.lstrip(xstr2, "0")
|
||||
xstr2 = str.upper(xstr2)
|
||||
|
||||
if xstr1 != xstr2:
|
||||
|
|
|
@ -11,8 +11,8 @@ except:
|
|||
print d, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = '%s' % d
|
||||
if str.find(s, 'ArithUnaryFunction') == -1:
|
||||
s = "%s" % d
|
||||
if str.find(s, "ArithUnaryFunction") == -1:
|
||||
print d, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
|
@ -23,8 +23,8 @@ except:
|
|||
print e, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = '%s' % e
|
||||
if str.find(s, 'ArithUnaryFunction') == -1:
|
||||
s = "%s" % e
|
||||
if str.find(s, "ArithUnaryFunction") == -1:
|
||||
print e, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
|
@ -40,8 +40,8 @@ except:
|
|||
print c, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = '%s' % c
|
||||
if str.find(s, 'ArithUnaryFunction') == -1:
|
||||
s = "%s" % c
|
||||
if str.find(s, "ArithUnaryFunction") == -1:
|
||||
print c, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
|
@ -52,8 +52,8 @@ except:
|
|||
print f, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = '%s' % f
|
||||
if str.find(s, 'ArithUnaryFunction') == -1:
|
||||
s = "%s" % f
|
||||
if str.find(s, "ArithUnaryFunction") == -1:
|
||||
print f, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
|
@ -68,8 +68,8 @@ except:
|
|||
print g, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = '%s' % g
|
||||
if str.find(s, 'ArithUnaryFunction') == -1:
|
||||
s = "%s" % g
|
||||
if str.find(s, "ArithUnaryFunction") == -1:
|
||||
print g, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
|
@ -81,8 +81,8 @@ except:
|
|||
print h, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = '%s' % h
|
||||
if str.find(s, 'ArithUnaryFunction') == -1:
|
||||
s = "%s" % h
|
||||
if str.find(s, "ArithUnaryFunction") == -1:
|
||||
print h, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ except:
|
|||
print d, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = '%s' % d
|
||||
if str.find(s, 'ArithUnaryFunction') == -1:
|
||||
s = "%s" % d
|
||||
if str.find(s, "ArithUnaryFunction") == -1:
|
||||
print d, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
|
@ -23,8 +23,8 @@ except:
|
|||
print e, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = '%s' % e
|
||||
if str.find(s, 'ArithUnaryFunction') == -1:
|
||||
s = "%s" % e
|
||||
if str.find(s, "ArithUnaryFunction") == -1:
|
||||
print e, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
|
@ -40,8 +40,8 @@ except:
|
|||
print c, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = '%s' % c
|
||||
if str.find(s, 'ArithUnaryFunction') == -1:
|
||||
s = "%s" % c
|
||||
if str.find(s, "ArithUnaryFunction") == -1:
|
||||
print c, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
|
@ -52,8 +52,8 @@ except:
|
|||
print f, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = '%s' % f
|
||||
if str.find(s, 'ArithUnaryFunction') == -1:
|
||||
s = "%s" % f
|
||||
if str.find(s, "ArithUnaryFunction") == -1:
|
||||
print f, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
|
@ -68,8 +68,8 @@ except:
|
|||
print g, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = '%s' % g
|
||||
if str.find(s, 'ArithUnaryFunction') == -1:
|
||||
s = "%s" % g
|
||||
if str.find(s, "ArithUnaryFunction") == -1:
|
||||
print g, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
|
@ -81,7 +81,7 @@ except:
|
|||
print h, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = '%s' % h
|
||||
if str.find(s, 'ArithUnaryFunction') == -1:
|
||||
s = "%s" % h
|
||||
if str.find(s, "ArithUnaryFunction") == -1:
|
||||
print h, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
|
|
@ -5,13 +5,13 @@ import unicode_strings
|
|||
# The 'u' string prefix isn't valid in Python 3.0 - 3.2 and is redundant
|
||||
# in 3.3+. Since this file is run through 2to3 before testing, though,
|
||||
# mark this as a unicode string in 2.x so it'll become a str in 3.x.
|
||||
test_string = u'h\udce9llo w\u00f6rld'
|
||||
test_string = u"h\udce9llo w\u00f6rld"
|
||||
|
||||
if sys.version_info[0:2] >= (3, 1):
|
||||
if unicode_strings.non_utf8_c_str() != test_string:
|
||||
raise ValueError('Test comparison mismatch')
|
||||
raise ValueError("Test comparison mismatch")
|
||||
if unicode_strings.non_utf8_std_string() != test_string:
|
||||
raise ValueError('Test comparison mismatch')
|
||||
raise ValueError("Test comparison mismatch")
|
||||
|
||||
def check(s1, s2):
|
||||
if s1 != s2:
|
||||
|
|
Loading…
Reference in New Issue