[pypy-svn] r18670 - in pypy/dist/pypy/interpreter: . test
arigo at codespeak.net
arigo at codespeak.net
Sun Oct 16 11:09:43 CEST 2005
Author: arigo
Date: Sun Oct 16 11:09:42 2005
New Revision: 18670
Modified:
pypy/dist/pypy/interpreter/function.py
pypy/dist/pypy/interpreter/test/test_function.py
Log:
More method object repr tweaking. Now we have the same as
CPython's user-defined methods. (No chance to get coherent
here, as CPython differs in the repr of user-defined or
built-in methods).
Fix the test.
Modified: pypy/dist/pypy/interpreter/function.py
==============================================================================
--- pypy/dist/pypy/interpreter/function.py (original)
+++ pypy/dist/pypy/interpreter/function.py Sun Oct 16 11:09:42 2005
@@ -270,7 +270,8 @@
s = "<unbound method %s.%s>" % (typename, name)
return space.wrap(s)
else:
- info = 'bound method %s.%s' % (typename, name)
+ objrepr = space.str_w(space.repr(self.w_instance))
+ info = 'bound method %s.%s of %s' % (typename, name, objrepr)
# info = "method %s of %s object" % (name, typename)
return self.w_instance.getrepr(self.space, info)
Modified: pypy/dist/pypy/interpreter/test/test_function.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_function.py (original)
+++ pypy/dist/pypy/interpreter/test/test_function.py Sun Oct 16 11:09:42 2005
@@ -194,20 +194,17 @@
assert (c.m != c.m) is False
def test_method_repr(self):
- assert repr(dict.items) == "<method 'items' of 'dict' objects>"
class A(object):
def f(self):
pass
- assert repr(A.f) == "<method 'f' of 'A' objects>"
- assert repr(A().f).startswith("<method f of A object at")
- assert repr(A.f.__get__(None)).startswith("<method f")
+ assert repr(A.f) == "<unbound method A.f>"
+ assert repr(A().f).startswith("<bound method A.f of <")
class B:
__metaclass__ = _classobj
def f(self):
pass
- assert repr(B.f) == "<method 'f' of 'B' objects>"
- assert repr(B().f).startswith("<method f of B object at")
- assert repr(B.f.__get__(None)).startswith("<method f")
+ assert repr(B.f) == "<unbound method B.f>"
+ assert repr(B().f).startswith("<bound method B.f of <")
class TestMethod:
def setup_method(self, method):
More information about the Pypy-commit
mailing list