Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3k
Changeset: r55224:b52cdc346162
Date: 2012-05-31 00:03 +0200
http://bitbucket.org/pypy/pypy/changeset/b52cdc346162/
Log: Fix various test failures
diff --git a/pypy/module/__builtin__/functional.py
b/pypy/module/__builtin__/functional.py
--- a/pypy/module/__builtin__/functional.py
+++ b/pypy/module/__builtin__/functional.py
@@ -326,6 +326,7 @@
def _compute_item(self, space, w_index):
w_zero = space.newint(0)
+ w_index = space.index(w_index)
if space.is_true(space.lt(w_index, w_zero)):
w_index = space.add(w_index, self.w_length)
if (space.is_true(space.ge(w_index, self.w_length)) or
diff --git a/pypy/module/pyexpat/test/test_parser.py
b/pypy/module/pyexpat/test/test_parser.py
--- a/pypy/module/pyexpat/test/test_parser.py
+++ b/pypy/module/pyexpat/test/test_parser.py
@@ -48,9 +48,9 @@
p.CharacterDataHandler = lambda s: data.append(s)
encoding = encoding_arg is None and 'utf-8' or encoding_arg
- res = p.Parse(u"<xml>\u00f6</xml>".encode(encoding),
isfinal=True)
+ res = p.Parse("<xml>\u00f6</xml>".encode(encoding),
isfinal=True)
assert res == 1
- assert data == [u"\u00f6"]
+ assert data == ["\u00f6"]
def test_get_handler(self):
import pyexpat
@@ -87,7 +87,7 @@
import pyexpat
p = pyexpat.ParserCreate()
def gotText(text):
- assert text == u"caf\xe9"
+ assert text == "caf\xe9"
p.CharacterDataHandler = gotText
assert p.returns_unicode
p.Parse(xml)
@@ -97,7 +97,7 @@
import pyexpat
p = pyexpat.ParserCreate(encoding='iso-8859-1')
def gotText(text):
- assert text == u"caf\xe9"
+ assert text == "caf\xe9"
p.CharacterDataHandler = gotText
p.Parse(xml)
@@ -107,7 +107,7 @@
import pyexpat
p = pyexpat.ParserCreate()
def gotText(text):
- assert text == u"caf\xe9"
+ assert text == "caf\xe9"
p.CharacterDataHandler = gotText
p.Parse(xml)
diff --git a/pypy/module/unicodedata/test/test_unicodedata.py
b/pypy/module/unicodedata/test/test_unicodedata.py
--- a/pypy/module/unicodedata/test/test_unicodedata.py
+++ b/pypy/module/unicodedata/test/test_unicodedata.py
@@ -75,13 +75,13 @@
char = chr(i)
try:
unicodedata.name(char)
- except ValueError, e:
+ except ValueError as e:
assert e.message == 'no such name'
raises(KeyError, unicodedata.lookup, charname)
def test_bug_1704793(self): # from CPython
import unicodedata
- assert unicodedata.lookup("GOTHIC LETTER FAIHU") == u'\U00010346'
+ assert unicodedata.lookup("GOTHIC LETTER FAIHU") == '\U00010346'
def test_normalize(self):
import unicodedata
@@ -91,14 +91,14 @@
import sys, unicodedata
if sys.maxunicode < 0x10ffff:
skip("requires a 'wide' python build.")
- assert unicodedata.normalize('NFC', u'\U000110a5\U000110ba') ==
u'\U000110ab'
+ assert unicodedata.normalize('NFC', '\U000110a5\U000110ba') ==
'\U000110ab'
def test_linebreaks(self):
linebreaks = (0x0a, 0x0b, 0x0c, 0x0d, 0x85,
0x1c, 0x1d, 0x1e, 0x2028, 0x2029)
for i in linebreaks:
for j in range(-2, 3):
- lines = (chr(i + j) + u'A').splitlines()
+ lines = (chr(i + j) + 'A').splitlines()
if i + j in linebreaks:
assert len(lines) == 2
else:
@@ -107,7 +107,7 @@
def test_mirrored(self):
import unicodedata
# For no reason, unicodedata.mirrored() returns an int, not a bool
- assert repr(unicodedata.mirrored(u' ')) == '0'
+ assert repr(unicodedata.mirrored(' ')) == '0'
class TestUnicodeData(object):
def setup_class(cls):
diff --git a/pypy/module/zlib/test/test_zlib.py
b/pypy/module/zlib/test/test_zlib.py
--- a/pypy/module/zlib/test/test_zlib.py
+++ b/pypy/module/zlib/test/test_zlib.py
@@ -76,7 +76,7 @@
assert v == -1
def test_crc32_negative_long_start(self):
- v = self.zlib.crc32(b'', -1L)
+ v = self.zlib.crc32(b'', -1)
assert v == -1
assert self.zlib.crc32(b'foo', -99999999999999999999999) == 1611238463
diff --git a/pypy/objspace/std/test/test_complexobject.py
b/pypy/objspace/std/test/test_complexobject.py
--- a/pypy/objspace/std/test/test_complexobject.py
+++ b/pypy/objspace/std/test/test_complexobject.py
@@ -396,10 +396,10 @@
fo = None
try:
pth = tempfile.mktemp()
- fo = open(pth,"wb")
+ fo = open(pth, "w")
print(a, b, file=fo)
fo.close()
- fo = open(pth, "rb")
+ fo = open(pth, "r")
res = fo.read()
assert res == "%s %s\n" % (a, b)
finally:
diff --git a/pypy/objspace/std/test/test_mapdict.py
b/pypy/objspace/std/test/test_mapdict.py
--- a/pypy/objspace/std/test/test_mapdict.py
+++ b/pypy/objspace/std/test/test_mapdict.py
@@ -815,7 +815,7 @@
assert res == (0, 1, 0)
def test_old_style_base(self):
- py.test.skip('py3k no longer has old style classes')
+ skip('py3k no longer has old style classes')
class B:
pass
class C(object):
diff --git a/pypy/objspace/std/test/test_ropeobject.py
b/pypy/objspace/std/test/test_ropeobject.py
--- a/pypy/objspace/std/test/test_ropeobject.py
+++ b/pypy/objspace/std/test/test_ropeobject.py
@@ -64,12 +64,6 @@
assert d['abcdefg'] == 2
-class TestUnicodeRopeObject(test_unicodeobject.TestUnicodeObject):
-
- def setup_class(cls):
- cls.space = gettestobjspace(**{"objspace.std.withrope": True})
-
-
class
AppTestUnicodeRopeStdOnly(test_unicodeobject.AppTestUnicodeStringStdOnly):
def setup_class(cls):
diff --git a/pypy/objspace/std/test/test_ropeunicodeobject.py
b/pypy/objspace/std/test/test_ropeunicodeobject.py
--- a/pypy/objspace/std/test/test_ropeunicodeobject.py
+++ b/pypy/objspace/std/test/test_ropeunicodeobject.py
@@ -3,12 +3,6 @@
from pypy.objspace.std.test import test_stringobject, test_unicodeobject
from pypy.conftest import gettestobjspace
-class TestRopeUnicodeObject(test_unicodeobject.TestUnicodeObject):
-
- def setup_class(cls):
- cls.space = gettestobjspace(**{"objspace.std.withropeunicode": True})
-
-
class AppTestRopeObject(test_stringobject.AppTestStringObject):
def setup_class(cls):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit