[Subversion] / DecoratorTools / test_decorators.py  

Diff of /DecoratorTools/test_decorators.py

Parent Directory | Revision Log

version 2722, Fri Apr 3 21:15:53 2015 UTC version 2727, Fri Apr 3 23:33:46 2015 UTC
Line 1 
Line 1 
 from unittest import TestCase, makeSuite, TestSuite  from unittest import TestCase, makeSuite, TestSuite
 from peak.util.decorators import *  from peak.util.decorators import *
   from peak.util.decorators import with_metaclass
 import sys  import sys
   
 def ping(log, value):  def ping(log, value):
Line 38 
Line 39 
   
   
   
   
 class DecoratorTests(TestCase):  class DecoratorTests(TestCase):
   
     def testAssignAdvice(self):      def testAssignAdvice(self):
Line 151 
Line 151 
   
     def testClassExec(self):      def testClassExec(self):
         d = {'sys':sys, 'frameinfo':frameinfo}          d = {'sys':sys, 'frameinfo':frameinfo}
         exec "class Foo: info=frameinfo(sys._getframe())" in d          exec("class Foo: info=frameinfo(sys._getframe())", d)
         kind,module,f_locals,f_globals = d['Foo'].info          kind,module,f_locals,f_globals = d['Foo'].info
         assert kind=="class", kind          assert kind=="class", kind
   
Line 207 
Line 207 
   
         class M(type): pass          class M(type): pass
   
         class C(M):          class C(with_metaclass(M, M)):
             __metaclass__ = M  
             ping([],1)              ping([],1)
   
         C, = C          C, = C
Line 220 
Line 219 
         class M1(type): pass          class M1(type): pass
         class M2(type): pass          class M2(type): pass
   
         class B1: __metaclass__ = M1          class B1(with_metaclass(M1)): pass
         class B2: __metaclass__ = M2          class B2(with_metaclass(M2)): pass
   
         try:          try:
             class C(B1,B2):              class C(B1,B2):
Line 233 
Line 232 
   
         class M3(M1,M2): pass          class M3(M1,M2): pass
   
         class C(B1,B2):          class C(with_metaclass(M3,B1,B2)):
             __metaclass__ = M3  
             ping([],1)              ping([],1)
   
         assert isinstance(C,list)          assert isinstance(C,list)
Line 244 
Line 242 
   
   
   
   
   
     def testMetaOfClass(self):      def testMetaOfClass(self):
   
         class metameta(type):          class metameta(type):
             pass              pass
   
         class meta(type):          class meta(with_metaclass(metameta, type)):
             __metaclass__ = metameta              pass
   
         assert metaclass_for_bases((meta,type))==metameta          assert metaclass_for_bases((meta,type))==metameta
   
   
   
 class ClassyMetaTests(TestCase):  class ClassyMetaTests(TestCase):
     """Test subclass/instance checking of classy for Python 2.6+ ABC mixin"""      """Test subclass/instance checking of classy for Python 2.6+ ABC mixin"""
   
       # avert 3.2 warnings, but still work on 2.3(!)
       failUnless = getattr(TestCase, 'assertTrue', TestCase.failUnless)
       failIf = getattr(TestCase, 'assertFalse', TestCase.failIf)
   
     def setUp(self):      def setUp(self):
         class x(classy): pass          class x(classy): pass
         class y(x): pass          class y(x): pass
Line 282 
Line 285 
   
   
   
   
   
   


Generate output suitable for use with a patch program
Legend:
Removed from v.2722  
changed lines
  Added in v.2727

cvs-admin@eby-sarna.com

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help