[pypy-commit] pypy list-strategies: unicode tests for liststrategies
l.diekmann
noreply at buildbot.pypy.org
Fri Sep 23 13:14:43 CEST 2011
Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: list-strategies
Changeset: r47517:4106cacd48f6
Date: 2011-07-19 11:50 +0200
http://bitbucket.org/pypy/pypy/changeset/4106cacd48f6/
Log: unicode tests for liststrategies
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -37,6 +37,7 @@
return space.fromcache(IntegerListStrategy)
# check for strings
+ #if all(is_W_StringObject(e) for e in list_w)
it = iter(list_w)
while(True):
try:
diff --git a/pypy/objspace/std/test/test_listobject.py b/pypy/objspace/std/test/test_listobject.py
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -1,3 +1,4 @@
+# coding: iso-8859-15
import random
from pypy.objspace.std.listobject import W_ListObject
from pypy.interpreter.error import OperationError
@@ -822,6 +823,20 @@
l.__delslice__(0, 2)
assert l == [3, 4]
+ def test_unicode(self):
+ s = u"���"
+ assert s.encode("ascii", "replace") == "???"
+ assert s.encode("ascii", "ignore") == ""
+
+ l1 = [s.encode("ascii", "replace")]
+ assert l1[0] == "???"
+
+ l2 = [s.encode("ascii", "ignore")]
+ assert l2[0] == ""
+
+ l3 = [s]
+ assert l1[0].encode("ascii", "replace") == "???"
+
class AppTestForRangeLists(AppTestW_ListObject):
def setup_class(cls):
diff --git a/pypy/objspace/std/test/test_liststrategies.py b/pypy/objspace/std/test/test_liststrategies.py
--- a/pypy/objspace/std/test/test_liststrategies.py
+++ b/pypy/objspace/std/test/test_liststrategies.py
@@ -338,3 +338,11 @@
from pypy.objspace.std.listobject import add__List_List
l3 = add__List_List(self.space, l1, l2)
assert self.space.eq_w(l3, W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3), self.space.wrap(4), self.space.wrap(5)]))
+
+ def test_unicode(self):
+ l1 = W_ListObject(self.space, [self.space.wrap("eins"), self.space.wrap("zwei")])
+ assert isinstance(l1.strategy, StringListStrategy)
+ l2 = W_ListObject(self.space, [self.space.wrap(u"eins"), self.space.wrap(u"zwei")])
+ assert isinstance(l2.strategy, ObjectListStrategy)
+ l3 = W_ListObject(self.space, [self.space.wrap("eins"), self.space.wrap(u"zwei")])
+ assert isinstance(l3.strategy, ObjectListStrategy)
More information about the pypy-commit
mailing list