/opt/imh-python/lib/python3.9/site-packages/zope/interface/tests
NameSizeModeActions
__pycache__/-0755rm
advisory_testing.py9000644editdlrm
dummy.py9130644editdlrm
idummy.py8900644editdlrm
m1.py8500644editdlrm
odd.py29670644editdlrm
test_adapter.py805080644editdlrm
test_advice.py60360644editdlrm
test_compile_flags.py12900644editdlrm
test_declarations.py830910644editdlrm
test_document.py172200644editdlrm
test_element.py11200644editdlrm
test_exceptions.py64450644editdlrm
test_interface.py927170644editdlrm
test_interfaces.py43950644editdlrm
test_odd_declarations.py76600644editdlrm
test_registry.py1125990644editdlrm
test_ro.py144650644editdlrm
test_sorting.py20510644editdlrm
test_verify.py192000644editdlrm
__init__.py42420644editdlrm
Edit: /opt/imh-python/lib/python3.9/site-packages/zope/interface/tests/odd.py (2967B)
############################################################################## # # Copyright (c) 2003 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Odd meta class that doesn't subclass type. This is used for testing support for ExtensionClass in new interfaces. >>> class A(object): ... __metaclass__ = MetaClass ... a = 1 ... >>> A.__name__ 'A' >>> A.__bases__ == (object,) True >>> class B(object): ... __metaclass__ = MetaClass ... b = 1 ... >>> class C(A, B): pass ... >>> C.__name__ 'C' >>> int(C.__bases__ == (A, B)) 1 >>> a = A() >>> aa = A() >>> a.a 1 >>> aa.a 1 >>> aa.a = 2 >>> a.a 1 >>> aa.a 2 >>> c = C() >>> c.a 1 >>> c.b 1 >>> c.b = 2 >>> c.b 2 >>> C.c = 1 >>> c.c 1 >>> int(C.__class__.__class__ is C.__class__) 1 """ # class OddClass is an odd meta class class MetaMetaClass(type): def __getattribute__(cls, name): if name == '__class__': return cls # Under Python 3.6, __prepare__ gets requested return type.__getattribute__(cls, name) class MetaClass: """Odd classes """ def __init__(self, name, bases, dict): self.__name__ = name self.__bases__ = bases self.__dict__.update(dict) def __call__(self): return OddInstance(self) def __getattr__(self, name): for b in self.__bases__: v = getattr(b, name, self) if v is not self: return v raise AttributeError(name) def __repr__(self): # pragma: no cover return f"" MetaClass = MetaMetaClass( 'MetaClass', MetaClass.__bases__, { k: v for k, v in MetaClass.__dict__.items() if k not in ('__dict__',) } ) class OddInstance: def __init__(self, cls): self.__dict__['__class__'] = cls def __getattribute__(self, name): dict = object.__getattribute__(self, '__dict__') if name == '__dict__': return dict v = dict.get(name, self) if v is not self: return v return getattr(dict['__class__'], name) def __setattr__(self, name, v): self.__dict__[name] = v def __delattr__(self, name): raise NotImplementedError() def __repr__(self): # pragma: no cover return "".format( self.__class__.__name__, hex(id(self)))