Commit 7e02bbc4 authored by Jeremy Hylton's avatar Jeremy Hylton

Make test output reproducible across runs.

parent 8270dce1
......@@ -85,12 +85,19 @@
__doc__='''Examples from the Acquisition Algebra Presentation
$Id: AqAlg.py,v 1.2 2000/06/19 20:30:52 jim Exp $'''
__version__='$Revision: 1.2 $'[11:-2]
$Id: test_AqAlg.py,v 1.1 2001/02/19 19:21:12 jeremy Exp $'''
__version__='$Revision: 1.1 $'[11:-2]
import Acquisition
import sys
def uid(obj, uids={}):
uid = uids.get(id(obj))
if uid is None:
uid = uids[id(obj)] = len(uids) + 1
return uid
def pretty(self, indent=0):
context=getattr(self, 'aq_parent', None)
if context is None: return self.__name__
......@@ -107,12 +114,10 @@ class I(Acquisition.Implicit):
def __init__(self, name):
self.__name__=name
def __str__(self):
context=getattr(self, 'aq_parent', None)
if context is None: return self.__name__
return "(%s: %s of %s)" % (id(self), self.aq_self, context)
return "(%s: %s of %s)" % (uid(self), self.aq_self, context)
__repr__=__str__
......
......@@ -5,7 +5,8 @@ class B(Base):
color='red'
class A(Acquisition.Implicit):
def hi(self): print self, self.color
def hi(self):
print "%s()" % self.__class__.__name__, self.color
b=B()
b.a=A()
......
from ExtensionClass import Base
from MethodObject import Method
class foo(Method):
def __call__(self,ob,*args,**kw): print 'called', ob, args, kw
def __call__(self, ob, *args, **kw):
print 'called', ob, args, kw
class bar(Base):
hi=foo()
def __repr__(self):
return "bar()"
hi = foo()
x=bar()
hi=x.hi
print hi
print type(hi)
hi(1,2,3,name='spam')
......@@ -5,7 +5,8 @@ class B(Base):
color='red'
class A(Acquisition.Explicit):
def hi(self): print self, self.acquire('color')
def hi(self):
print self.__class__.__name__, self.acquire('color')
b=B()
b.a=A()
......
import ExtensionClass
class C(ExtensionClass.Base):
def __call_method__(self,meth,args,kw={}):
def __call_method__(self, meth, args, kw={}):
print 'give us a hook, hook, hook...'
apply(meth,args,kw)
return apply(meth, args, kw)
def hi(self,*args,**kw): print self, args, kw
def hi(self, *args, **kw):
print "%s()" % self.__class__.__name__, args, kw
c=C()
c.hi()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment