home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 June / maximum-cd-2009-06.iso / DiscContents / digsby_setup.exe / lib / protocols / tests / test_advice.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-02-26  |  5.1 KB  |  130 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from unittest import TestCase, makeSuite, TestSuite
  5. from protocols.advice import *
  6. import sys
  7. from types import InstanceType
  8.  
  9. class SuperTest(TestCase):
  10.     
  11.     def checkMetaSuper(self):
  12.         
  13.         class Meta(type):
  14.             
  15.             def foo(self, arg):
  16.                 return arg
  17.  
  18.             foo = metamethod(foo)
  19.  
  20.         
  21.         class Class((object,)):
  22.             __metaclass__ = Meta
  23.             
  24.             def foo(self, arg):
  25.                 return arg * 2
  26.  
  27.  
  28.         
  29.         class SubMeta((Meta,)):
  30.             
  31.             def foo(self, arg):
  32.                 return -supermeta(SubMeta, self).foo(arg)
  33.  
  34.             foo = metamethod(foo)
  35.  
  36.         
  37.         class ClassOfSubMeta((Class,)):
  38.             __metaclass__ = SubMeta
  39.  
  40.  
  41.     
  42.     def checkPropSuper(self):
  43.         
  44.         class Base(object):
  45.             __slots__ = 'foo'
  46.  
  47.         
  48.         class Sub('Sub', (Base,)):
  49.             
  50.             def getFoo(self):
  51.                 return supermeta(Sub, self).foo * 2
  52.  
  53.             
  54.             def setFoo(self, val):
  55.                 Base.foo.__set__(self, val)
  56.  
  57.             foo = property(getFoo, setFoo)
  58.  
  59.         ob = Sub()
  60.         ob.foo = 1
  61.  
  62.     
  63.     def checkSuperNotFound(self):
  64.         
  65.         class Base(object):
  66.             pass
  67.  
  68.         b = Base()
  69.         
  70.         try:
  71.             supermeta(Base, b).foo
  72.         except AttributeError:
  73.             pass
  74.  
  75.         raise AssertionError("Shouldn't have returned a value")
  76.  
  77.  
  78.  
  79. class MROTests(TestCase):
  80.     
  81.     def checkStdMRO(self):
  82.         
  83.         class foo(object):
  84.             pass
  85.  
  86.         
  87.         class bar(foo):
  88.             pass
  89.  
  90.         
  91.         class baz(foo):
  92.             pass
  93.  
  94.         
  95.         class spam(bar, baz):
  96.             pass
  97.  
  98.  
  99.     
  100.     def checkClassicMRO(self):
  101.         
  102.         class foo:
  103.             pass
  104.  
  105.         
  106.         class bar(foo):
  107.             pass
  108.  
  109.         
  110.         class baz(foo):
  111.             pass
  112.  
  113.         
  114.         class spam(bar, baz):
  115.             pass
  116.  
  117.         basicMRO = [
  118.             spam,
  119.             bar,
  120.             foo,
  121.             baz,
  122.             foo]
  123.  
  124.  
  125. TestClasses = (SuperTest, MROTests)
  126.  
  127. def test_suite():
  128.     return []([ makeSuite(t, 'check') for t in TestClasses ])
  129.  
  130.