PageRenderTime 33ms CodeModel.GetById 24ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/logilab-astng-0.23.1/test/data/module.py

#
Python | 89 lines | 66 code | 15 blank | 8 comment | 18 complexity | 6ddfd311d66dae7b32dbfb4cddc48c54 MD5 | raw file
 1"""test module for astng
 2"""
 3
 4__revision__ = '$Id: module.py,v 1.2 2005-11-02 11:56:54 syt Exp $'
 5from logilab.common import modutils
 6from logilab.common.shellutils import Execute as spawn
 7from logilab.astng.utils import *
 8import os.path
 9MY_DICT = {}
10
11def global_access(key, val):
12    """function test"""
13    local = 1
14    MY_DICT[key] = val
15    for i in val:
16        if i:
17            del MY_DICT[i]
18            continue
19        else:
20            break
21    else:
22        print '!!!'
23
24
25class YO:
26    """hehe"""
27    a = 1
28    
29    def __init__(self):
30        try:
31            self.yo = 1
32        except ValueError, ex:
33            pass
34        except (NameError, TypeError):
35            raise XXXError()
36        except:
37            raise
38
39
40
41class YOUPI(YO):
42    class_attr = None
43    
44    def __init__(self):
45        self.member = None
46    
47    def method(self):
48        """method test"""
49        global MY_DICT
50        try:
51            MY_DICT = {}
52            local = None
53            autre = [a for (a, b) in MY_DICT if b]
54            if b in autre:
55                print 'yo',
56            else:
57                if a in autre:
58                    print 'hehe'
59            global_access(local, val=autre)
60        finally:
61            return local
62    
63    def static_method():
64        """static method test"""
65        assert MY_DICT, '???'
66    static_method = staticmethod(static_method)
67    
68    def class_method(cls):
69        """class method test"""
70        exec a in b
71    class_method = classmethod(class_method)
72
73
74def four_args(a, b, c, d):
75    """four arguments (was nested_args)"""
76    print a, b, c, d
77    while 1:
78        if a:
79            break
80        a += +1
81    else:
82        b += -2
83    if c:
84        d = ((a) and (b)) or (c)
85    else:
86        c = ((a) and (b)) or (d)
87    map(lambda x, y: (y, x), a)
88redirect = four_args
89