gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.app / org.gvsig.scripting.app.mainplugin / src / main / resources-plugin / scripting / lib / pylint / test / functional / class_members_py27.py @ 745
History | View | Annotate | Download (1.71 KB)
1 |
""" Various tests for class members access. """
|
---|---|
2 |
# pylint: disable=R0903,print-statement,no-absolute-import, metaclass-assignment,import-error,no-init,missing-docstring, wrong-import-order,wrong-import-position
|
3 |
from missing import Missing |
4 |
class MyClass(object): |
5 |
"""class docstring"""
|
6 |
|
7 |
def __init__(self): |
8 |
"""init"""
|
9 |
self.correct = 1 |
10 |
|
11 |
def test(self): |
12 |
"""test"""
|
13 |
self.correct += 2 |
14 |
self.incorrect += 2 # [no-member] |
15 |
del self.havenot # [no-member] |
16 |
self.nonexistent1.truc() # [no-member] |
17 |
self.nonexistent2[1] = 'hehe' # [no-member] |
18 |
|
19 |
class XYZMixin(object): |
20 |
"""access to undefined members should be ignored in mixin classes by
|
21 |
default
|
22 |
"""
|
23 |
def __init__(self): |
24 |
print self.nonexistent |
25 |
|
26 |
|
27 |
class NewClass(object): |
28 |
"""use object.__setattr__"""
|
29 |
def __init__(self): |
30 |
self.__setattr__('toto', 'tutu') |
31 |
|
32 |
from abc import ABCMeta |
33 |
|
34 |
class TestMetaclass(object): |
35 |
""" Test attribute access for metaclasses. """
|
36 |
__metaclass__ = ABCMeta |
37 |
|
38 |
class Metaclass(type): |
39 |
""" metaclass """
|
40 |
@classmethod
|
41 |
def test(mcs): |
42 |
""" classmethod """
|
43 |
|
44 |
class UsingMetaclass(object): |
45 |
""" empty """
|
46 |
__metaclass__ = Metaclass |
47 |
|
48 |
#TestMetaclass.register(int)
|
49 |
#UsingMetaclass.test()
|
50 |
TestMetaclass().register(int) # [no-member] |
51 |
UsingMetaclass().test() # [no-member]
|
52 |
|
53 |
|
54 |
class NoKnownBases(Missing): |
55 |
"""Don't emit no-member if we don't know the bases of a class."""
|
56 |
|
57 |
NoKnownBases().lalala() |
58 |
|
59 |
# Should be enabled on astroid > 1.4.0
|
60 |
#class MetaClass(object):
|
61 |
# """Look some methods in the implicit metaclass."""
|
62 |
#
|
63 |
# @classmethod
|
64 |
# def whatever(cls):
|
65 |
# return cls.mro() + cls.missing()
|