| 1 |
"""test module for astroid |
| 2 |
""" |
| 3 |
|
| 4 |
__revision__ = '$Id: module.py,v 1.2 2005-11-02 11:56:54 syt Exp $' |
| 5 |
from astroid.nodes import Name as NameNode |
| 6 |
from astroid import modutils |
| 7 |
from astroid.utils import * |
| 8 |
import os.path |
| 9 |
MY_DICT = {} |
| 10 |
|
| 11 |
def 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 |
return |
| 23 |
|
| 24 |
|
| 25 |
class YO: |
| 26 |
"""hehe |
| 27 |
haha""" |
| 28 |
a = 1 |
| 29 |
|
| 30 |
def __init__(self): |
| 31 |
try: |
| 32 |
self.yo = 1 |
| 33 |
except ValueError as ex: |
| 34 |
pass |
| 35 |
except (NameError, TypeError): |
| 36 |
raise XXXError() |
| 37 |
except: |
| 38 |
raise |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
class YOUPI(YO): |
| 43 |
class_attr = None |
| 44 |
|
| 45 |
def __init__(self): |
| 46 |
self.member = None |
| 47 |
|
| 48 |
def method(self): |
| 49 |
"""method |
| 50 |
test""" |
| 51 |
global MY_DICT |
| 52 |
try: |
| 53 |
MY_DICT = {} |
| 54 |
local = None |
| 55 |
autre = [a for (a, b) in MY_DICT if b] |
| 56 |
if b in autre: |
| 57 |
return |
| 58 |
elif a in autre: |
| 59 |
return 'hehe' |
| 60 |
global_access(local, val=autre) |
| 61 |
finally: |
| 62 |
# return in finally was previously tested here but became a syntax error |
| 63 |
# in 3.14 and this file is used in 188/1464 tests |
| 64 |
a = local |
| 65 |
|
| 66 |
def static_method(): |
| 67 |
"""static method test""" |
| 68 |
assert MY_DICT, '???' |
| 69 |
static_method = staticmethod(static_method) |
| 70 |
|
| 71 |
def class_method(cls): |
| 72 |
"""class method test""" |
| 73 |
exec(a, b) |
| 74 |
class_method = classmethod(class_method) |
| 75 |
|
| 76 |
|
| 77 |
def four_args(a, b, c, d): |
| 78 |
"""four arguments (was nested_args)""" |
| 79 |
while 1: |
| 80 |
if a: |
| 81 |
break |
| 82 |
a += +1 |
| 83 |
else: |
| 84 |
b += -2 |
| 85 |
if c: |
| 86 |
d = a and (b or c) |
| 87 |
else: |
| 88 |
c = a and b or d |
| 89 |
list(map(lambda x, y: (y, x), a)) |
| 90 |
redirect = four_args |
| 91 |
|