[Zope-Checkins] CVS: Zope2 - test_Sync.py:1.3.120.1 test_ThreadLock.py:1.3.120.1 test_acquisition.py:1.2.36.1 test_binding.py:1.1.122.1 test_explicit_acquisition.py:1.1.122.1 test_method_hook.py:1.2.122.1

Brian Lloyd brian@digiciool.com
Wed, 14 Mar 2001 14:05:13 -0500 (EST)


Update of /cvs-repository/Zope2/lib/Components/ExtensionClass/test
In directory korak:/home/brian/temp/zope-23-branch/lib/Components/ExtensionClass/test

Modified Files:
      Tag: zope-2_3-branch
	test_Sync.py test_ThreadLock.py test_acquisition.py 
	test_binding.py test_explicit_acquisition.py 
	test_method_hook.py 
Log Message:
Merge warning fixes and test updated missed from trunk



--- Updated File test_Sync.py in package Zope2 --
--- test_Sync.py	1999/06/08 18:56:52	1.3
+++ test_Sync.py	2001/03/14 19:05:13	1.3.120.1
@@ -1,36 +1,46 @@
-
 from Sync import Synchronized
 import thread
 from random import random
 from time import sleep
 
-
 class P(Synchronized):
 
     def __init__(self,*args,**kw):
         self.count=0
 
     def inc(self):
-            c=self.count
-            sleep(random())
-            self.count=self.count+1
-            return c,self.count
+            c = self.count
+            if random() > 0.7:
+                sleep(1)
+            self.count = self.count + 1
+            return c, self.count
 
     def incn(self,n):
-            c=self.count
-            for i in range(n): self.inc()
-            return c,self.count
+            c = self.count
+            for i in range(n):
+                self.inc()
+            return c, self.count
         
-p=P(1,2,spam=3)
+p = P(1, 2, spam=3)
 
 def test():
-    
-    for i in range(10):
-        n=3
-        old,new=p.incn(n)
-        print old,new
-        if old+n != new: print 'oops'
-
+    for i in range(8):
+        n = 3
+        old, new = p.incn(n)
+        if old + n != new:
+            print 'oops'
+        sleep(2)
+    thread_finished()
+
+def thread_finished(lock=thread.allocate_lock()):
+    global num_threads
+    lock.acquire()
+    num_threads = num_threads - 1
+    lock.release()
+
+num_threads = 8
+for i in range(num_threads):
+    thread.start_new_thread(test, ())
 
-for i in range(10): thread.start_new_thread(test,())
-sleep(50)
+while num_threads > 0:
+    sleep(1)

--- Updated File test_ThreadLock.py in package Zope2 --
--- test_ThreadLock.py	1999/06/08 18:57:31	1.3
+++ test_ThreadLock.py	2001/03/14 19:05:13	1.3.120.1
@@ -1,4 +1,3 @@
-
 import ThreadLock, thread
 from random import random
 from time import sleep
@@ -30,7 +29,8 @@
 
     def inc(self):
             c=self.count
-            sleep(random())
+            if random() > 0.7:
+                sleep(1)
             self.count=self.count+1
             return c,self.count
 
@@ -43,12 +43,24 @@
 
 def test():
     
-    for i in range(10):
-        n=3
-        old,new=p.incn(n)
-        print old,new
-        if old+n != new: print 'oops'
-
+    for i in range(8):
+        n = 3
+        old, new = p.incn(n)
+        if old + n != new:
+            print 'oops'
+        sleep(3)
+    thread_finished()
+
+
+def thread_finished(lock=thread.allocate_lock()):
+    global num_threads
+    lock.acquire()
+    num_threads = num_threads - 1
+    lock.release()
+
+num_threads = 8
+for i in range(num_threads):
+    thread.start_new_thread(test, ())
 
-for i in range(10): thread.start_new_thread(test,())
-sleep(50)
+while num_threads > 0:
+    sleep(1)

--- Updated File test_acquisition.py in package Zope2 --
--- test_acquisition.py	2000/09/29 17:21:27	1.2
+++ test_acquisition.py	2001/03/14 19:05:13	1.2.36.1
@@ -5,7 +5,8 @@
     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()

--- Updated File test_binding.py in package Zope2 --
--- test_binding.py	1998/11/18 14:08:26	1.1
+++ test_binding.py	2001/03/14 19:05:13	1.1.122.1
@@ -1,15 +1,17 @@
-
 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')
 

--- Updated File test_explicit_acquisition.py in package Zope2 --
--- test_explicit_acquisition.py	1998/11/18 14:08:26	1.1
+++ test_explicit_acquisition.py	2001/03/14 19:05:13	1.1.122.1
@@ -5,7 +5,8 @@
     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()

--- Updated File test_method_hook.py in package Zope2 --
--- test_method_hook.py	1998/12/04 20:59:26	1.2
+++ test_method_hook.py	2001/03/14 19:05:13	1.2.122.1
@@ -1,13 +1,13 @@
-
 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()