0001 # 0002 # Tests for new language features in 2.4 0003 # 0004 0005 # test of new import 0006 from sys import ( 0007 argv, 0008 exit, 0009 path) 0010 0011 0012 # test of decorators 0013 def decorator(x): 0014 return x 0015 0016 @decorator 0017 def decorated(a): 0018 print a 0019 0020 # another test of decorators 0021 class Other(object): 0022 @classmethod 0023 def foo(c): pass 0024 0025 def om(self): pass 0026 0027 #decorator test from test\test_decorators.py 0028 class TestDecorators(unittest.TestCase): 0029 def test_dotted(self): 0030 decorators = MiscDecorators() 0031 @decorators.author('Cleese') 0032 def foo(): return 42 0033 self.assertEqual(foo(), 42) 0034 self.assertEqual(foo.author, 'Cleese') 0035 0036 # test of generator expressions 0037 0038 lst = [1,2,3,4,5,6,7] 0039 0040 print decorated(item for item in lst if item % 2 == 0) 0041 0042
Generated by PyXR 0.9.4