pypy/objspace/std/test/test_unicodeobject.py::AppTestUnicodeString::()::test_str_unicode_concat_overrides
self = <pypy.interpreter.typedef.W_ObjectObjectUserDictWeakrefable object at 0x1c33d9f0>
def test_str_unicode_concat_overrides(self):
"Test from Jython about being bug-compatible with CPython."
def check(value, expected):
assert type(value) == type(expected)
assert value == expected
def _test_concat(t1, t2):
tprecedent = str
if issubclass(t1, unicode) or issubclass(t2, unicode):
tprecedent = unicode
class SubclassB(t2):
def __add__(self, other):
return SubclassB(t2(self) + t2(other))
check(SubclassB('py') + SubclassB('thon'), SubclassB('python'))
check(t1('python') + SubclassB('3'), tprecedent('python3'))
check(SubclassB('py') + t1('py'), SubclassB('pypy'))
class SubclassC(t2):
def __radd__(self, other):
return SubclassC(t2(other) + t2(self))
check(SubclassC('stack') + SubclassC('less'), t2('stackless'))
check(t1('iron') + SubclassC('python'), SubclassC('ironpython'))
check(SubclassC('tiny') + t1('py'), tprecedent('tinypy'))
class SubclassD(t2):
def __add__(self, other):
return SubclassD(t2(self) + t2(other))
def __radd__(self, other):
return SubclassD(t2(other) + t2(self))
check(SubclassD('di') + SubclassD('ct'), SubclassD('dict'))
check(t1('list') + SubclassD(' comp'), SubclassD('list comp'))
check(SubclassD('dun') + t1('der'), SubclassD('dunder'))
> _test_concat(str, str)
[/buildbot/slave/own-linux-x86-32/build/pypy/objspace/std/test/test_unicodeobject.py:402]:37:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
t1 = <W_TypeObject 'str' at 0x1d9ff870>, t2 = <W_TypeObject 'str' at 0x1d9ff870>
def _test_concat(t1, t2):
tprecedent = str
> if issubclass(t1, unicode) or issubclass(t2, unicode):
E (application-level) NameError: name 'unicode' is not defined
[/buildbot/slave/own-linux-x86-32/build/pypy/objspace/std/test/test_unicodeobject.py:402]:10: NameError
builder: own-linux-x86-32 build #9465+
test: pypy/objspace/std/test/test_unicodeobject.py::AppTestUnicodeString::()::test_str_unicode_concat_overrides