diff options
Diffstat (limited to 'test/functional/abstract_class_instantiated_py3.py')
-rw-r--r-- | test/functional/abstract_class_instantiated_py3.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/functional/abstract_class_instantiated_py3.py b/test/functional/abstract_class_instantiated_py3.py index 146666e..8d94733 100644 --- a/test/functional/abstract_class_instantiated_py3.py +++ b/test/functional/abstract_class_instantiated_py3.py @@ -10,6 +10,7 @@ abstract methods. __revision__ = 0 import abc +import weakref class GoodClass(object, metaclass=abc.ABCMeta): pass @@ -38,11 +39,60 @@ class ThirdBadClass(SecondBadClass): pass +class Structure(object, metaclass=abc.ABCMeta): + @abc.abstractmethod + def __iter__(self): + pass + @abc.abstractmethod + def __len__(self): + pass + @abc.abstractmethod + def __contains__(self): + pass + @abc.abstractmethod + def __hash__(self): + pass + +class Container(Structure): + def __contains__(self): + pass + +class Sizable(Structure): + def __len__(self): + pass + +class Hashable(Structure): + __hash__ = 42 + + +class Iterator(Structure): + def keys(self): # pylint: disable=no-self-use + return iter([1, 2, 3]) + + __iter__ = keys + +class AbstractSizable(Structure): + @abc.abstractmethod + def length(self): + pass + __len__ = length + +class NoMroAbstractMethods(Container, Iterator, Sizable, Hashable): + pass + +class BadMroAbstractMethods(Container, Iterator, AbstractSizable): + pass + def main(): """ do nothing """ GoodClass() SecondGoodClass() ThirdGoodClass() + weakref.WeakKeyDictionary() + weakref.WeakValueDictionary() + NoMroAbstractMethods() + + BadMroAbstractMethods() # [abstract-class-instantiated] BadClass() # [abstract-class-instantiated] SecondBadClass() # [abstract-class-instantiated] ThirdBadClass() # [abstract-class-instantiated] |