[prev in list] [next in list] [prev in thread] [next in thread]
List: python-3000-checkins
Subject: [Python-3000-checkins] r45583 - in python/branches/p3yk/Lib:
From: python-3000-checkins () python ! org (guido ! van ! rossum)
Date: 2006-04-20 16:07:40
Message-ID: 20060420160740.1B5BE1E400B () bag ! python ! org
[Download RAW message or body]
Author: guido.van.rossum
Date: Thu Apr 20 18:07:39 2006
New Revision: 45583
Modified:
python/branches/p3yk/Lib/repr.py
python/branches/p3yk/Lib/test/test_repr.py
Log:
Fix test failures for repr.py.
But shouldn't we kill this module? How many pprint clones do we need?
Modified: python/branches/p3yk/Lib/repr.py
==============================================================================
--- python/branches/p3yk/Lib/repr.py (original)
+++ python/branches/p3yk/Lib/repr.py Thu Apr 20 18:07:39 2006
@@ -18,7 +18,7 @@
self.maxdeque = 6
self.maxstring = 30
self.maxlong = 40
- self.maxother = 20
+ self.maxother = 30
def repr(self, x):
return self.repr1(x, self.maxlevel)
@@ -31,12 +31,7 @@
if hasattr(self, 'repr_' + typename):
return getattr(self, 'repr_' + typename)(x, level)
else:
- s = __builtin__.repr(x)
- if len(s) > self.maxother:
- i = max(0, (self.maxother-3)//2)
- j = max(0, self.maxother-3-i)
- s = s[:i] + '...' + s[len(s)-j:]
- return s
+ return self.repr_instance(x, level)
def _repr_iterable(self, x, level, left, right, maxiter, trail=''):
n = len(x)
@@ -112,9 +107,9 @@
# exceptions -- then make up something
except:
return '<%s instance at %x>' % (x.__class__.__name__, id(x))
- if len(s) > self.maxstring:
- i = max(0, (self.maxstring-3)//2)
- j = max(0, self.maxstring-3-i)
+ if len(s) > self.maxother:
+ i = max(0, (self.maxother-3)//2)
+ j = max(0, self.maxother-3-i)
s = s[:i] + '...' + s[len(s)-j:]
return s
Modified: python/branches/p3yk/Lib/test/test_repr.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_repr.py (original)
+++ python/branches/p3yk/Lib/test/test_repr.py Thu Apr 20 18:07:39 2006
@@ -111,7 +111,7 @@
s = r(ClassWithFailingRepr)
self.failUnless(s.startswith("<class "))
self.failUnless(s.endswith(">"))
- self.failUnless(s.find("...") == 8)
+ self.failUnless(s.find("...") in [12, 13])
def test_file(self):
fp = open(unittest.__file__)
@@ -249,8 +249,7 @@
''')
from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation \
import bar # Module name may be prefixed with "test.", depending on how run.
- self.failUnless(repr(bar.bar).startswith(
- "<class %s.bar at 0x" % bar.__name__))
+ self.assertEquals(repr(bar.bar), "<class '%s.bar'>" % bar.__name__)
def test_instance(self):
touch(os.path.join(self.subpkgname, 'baz'+os.extsep+'py'), '''\
@@ -260,7 +259,7 @@
from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation \
import baz ibaz = baz.baz()
self.failUnless(repr(ibaz).startswith(
- "<%s.baz instance at 0x" % baz.__name__))
+ "<%s.baz object at 0x" % baz.__name__))
def test_method(self):
eq = self.assertEquals
@@ -275,7 +274,7 @@
# Bound method next
iqux = qux.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
self.failUnless(repr(iqux.amethod).startswith(
- '<bound method \
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.amethod \
of <%s.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
instance at 0x' \ + '<bound method \
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.amethod \
of <%s.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
object at 0x' \ % (qux.__name__,) ))
def test_builtin_function(self):
@@ -286,7 +285,7 @@
def __init__(self, s):
self.s = s
def __repr__(self):
- return "ClassWithLongRepr(%r)" % self.s
+ return "ClassWithRepr(%r)" % self.s
class ClassWithFailingRepr:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic