HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/zope/interface/tests/__pycache__/test_declarations.cpython-38.pyc
U

ؒ�]>��@sddZddlZddlmZGdd�de�ZGdd�dej�ZGdd	�d	ej�ZGd
d�dej�Z	Gdd
�d
ej�Z
Gdd�de
�ZGdd�dej�ZGdd�dej�Z
Gdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�deje�ZGdd�deje�ZGdd�dej�ZGd d!�d!ej�ZGd"d#�d#ej�ZGd$d%�d%ej�ZGd&d'�d'ej�ZGd(d)�d)ej�ZGd*d+�d+e�ZGd,d-�d-ej�ZGd.d/�d/ej�ZGd0d1�d1eje�ZGd2d3�d3ej�ZGd4d5�d5ej�ZGd6d7�d7ej�ZGd8d9�d9e�Z Gd:d;�d;ej�Z!Gd<d=�d=e!�Z"Gd>d?�d?ej�Z#Gd@dA�dAe#�Z$GdBdC�dCe�Z%GdDdE�dEe�Z&dS)Fz@Test the new API for making and checking interface declarations
�N)�_skip_under_py3kc@seZdZddd�ZdS)�_Py3ClassAdviceTc	Cs�ddl}ddlm}|jdd��|}|��|sXt|||�|�t|�d�W5QR�dSzt|||�Wn tk
r�YW5QR�dSX|r�|�	d�W5QRXdS)Nr��PYTHON3T��recordF�Didn't raise TypeError)
�warnings�zope.interface._compatr�catch_warnings�
resetwarnings�exec�assertEqual�len�	TypeError�fail)�self�code�globs�locsZfails_under_py3kr	r�log�r�H/usr/lib/python3/dist-packages/zope/interface/tests/test_declarations.py�_run_generated_codesz#_Py3ClassAdvice._run_generated_codeN)T)�__name__�
__module__�__qualname__rrrrrrs�rc@s$eZdZdd�Zdd�Zdd�ZdS)�
NamedTestscCs6ddlm}|d�Gdd�dt��}|�|jd�dS)Nr��named�fooc@seZdZdS)z"NamedTests.test_class.<locals>.FooN�rrrrrrr�Foo1sr"��zope.interface.declarationsr�objectr�__component_name__)rrr"rrr�
test_class.szNamedTests.test_classcCs.ddlm}|d�dd��}|�|jd�dS)Nrrr cSs
t��dS�N��NotImplementedError)�orrr�doFoo:sz'NamedTests.test_function.<locals>.doFoo)r$rrr&)rrr,rrr�
test_function7s
zNamedTests.test_functioncCs@ddlm}Gdd�dt�}|�}|d�|�|�|jd�dS)Nrrc@seZdZdS)z%NamedTests.test_instance.<locals>.FooNr!rrrrr"Csr"r r#)rrr"r rrr�
test_instance@s
zNamedTests.test_instanceN)rrrr'r-r.rrrrr,s		rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3S)4�DeclarationTestscCsddlm}|S)Nr)�Declaration)r$r0)rr0rrr�_getTargetClassMsz DeclarationTests._getTargetClasscOs|��||�Sr(�r1�r�args�kwrrr�_makeOneQszDeclarationTests._makeOnecCs|��}|�t|j�g�dSr()r6r�list�	__bases__�r�declrrr�test_ctor_no_basesTsz#DeclarationTests.test_ctor_no_basescCs6ddlm}|d�}|�|�}|�t|j�|g�dS�Nr��InterfaceClass�IFoo)�zope.interface.interfacer>r6rr7r8�rr>r?r:rrr�test_ctor_w_interface_in_basesXs
z/DeclarationTests.test_ctor_w_interface_in_basescCs4ddlm}|�}|�|�}|�t|j�|g�dS�Nr��
Implements)r$rEr6rr7r8)rrE�implr:rrr�test_ctor_w_implements_in_bases^s
z0DeclarationTests.test_ctor_w_implements_in_basescCs&|��}|�|�|�d|jk�dS�N�_v_attrs)r6�changed�assertFalse�__dict__r9rrr�!test_changed_wo_existing__v_attrsds
z2DeclarationTests.test_changed_wo_existing__v_attrscCs.|��}t�|_|�|�|�d|jk�dSrH)r6r%rIrJrKrLr9rrr� test_changed_w_existing__v_attrsis
z1DeclarationTests.test_changed_w_existing__v_attrscCs.ddlm}|d�}|��}|�||k�dSr<�r@r>r6rKrArrr�test___contains__w_selfosz(DeclarationTests.test___contains__w_selfcCs.ddlm}|d�}|��}|�||k�dSr<rOrArrr�"test___contains__w_unrelated_ifaceusz3DeclarationTests.test___contains__w_unrelated_ifacecCs0ddlm}|d�}|�|�}|�||k�dSr<)r@r>r6�
assertTruerArrr�!test___contains__w_base_interface{s
z2DeclarationTests.test___contains__w_base_interfacecCs|��}|�t|�g�dSr()r6rr7r9rrr�test___iter___empty�sz$DeclarationTests.test___iter___emptycCs4ddlm}|d�}|�|�}|�t|�|g�dSr<�r@r>r6rr7rArrr�test___iter___single_base�s
z*DeclarationTests.test___iter___single_basecCs@ddlm}|d�}|d�}|�||�}|�t|�||g�dS�Nrr=r?�IBarrU�rr>r?rXr:rrr�test___iter___multiple_bases�s
z-DeclarationTests.test___iter___multiple_basescCs@ddlm}|d�}|d|f�}|�|�}|�t|�|g�dSrWrUrYrrr�test___iter___inheritance�s

z*DeclarationTests.test___iter___inheritancecCsDddlm}|d�}|d�}|�|||f�}|�t|�||g�dSrWrUrYrrr�'test___iter___w_nested_sequence_overlap�s
z8DeclarationTests.test___iter___w_nested_sequence_overlapcCs.ddlm}|��}|�t|���|g�dS)Nr��	Interface)r@r^r6rr7�	flattened)rr^r:rrr�test_flattened_empty�sz%DeclarationTests.test_flattened_emptycCsFddlm}ddlm}|d�}|�|�}|�t|���||g�dS)Nrr]r=r?�r@r^r>r6rr7r_)rr^r>r?r:rrr�test_flattened_single_base�s

z+DeclarationTests.test_flattened_single_basecCsRddlm}ddlm}|d�}|d�}|�||�}|�t|���|||g�dS�Nrr]r=r?rXra�rr^r>r?rXr:rrr�test_flattened_multiple_bases�sz.DeclarationTests.test_flattened_multiple_basescCsTddlm}ddlm}|d�}|d|f�}|�|�}|�t|���|||g�dSrcrardrrr�test_flattened_inheritance�s
z+DeclarationTests.test_flattened_inheritancecCsVddlm}ddlm}|d�}|d�}|�|||f�}|�t|���|||g�dSrcrardrrr�(test_flattened_w_nested_sequence_overlap�sz9DeclarationTests.test_flattened_w_nested_sequence_overlapcCsXddlm}|d�}|d�}|�|�}||}|�t||����|�t|�|g�dSrW�r@r>r6rR�
isinstancer1rr7�rr>r?rX�before�afterrrr� test___sub___unrelated_interface�s
z1DeclarationTests.test___sub___unrelated_interfacecCs:ddlm}|d�}|�|�}||}|�t|�g�dSr<rU)rr>r?rkrlrrr�test___sub___related_interface�s

z/DeclarationTests.test___sub___related_interfacecCsFddlm}|d�}|d|f�}|�|�}||}|�t|�g�dSrWrUrjrrr�-test___sub___related_interface_by_inheritance�s
z>DeclarationTests.test___sub___related_interface_by_inheritancecCsZddlm}|d�}|d�}|�|�}||}|�t||����|�t|�||g�dSrWrhrjrrr� test___add___unrelated_interface�s
z1DeclarationTests.test___add___unrelated_interfacecCs^ddlm}|d�}|d�}|d�}|�||�}|�||�}||}|�t|�|||g�dS)Nrr=r?rX�IBazrU)rr>r?rXrqrk�otherrlrrr�test___add___related_interface�sz/DeclarationTests.test___add___related_interfaceN)rrrr1r6r;rBrGrMrNrPrQrSrTrVrZr[r\r`rbrerfrgrmrnrorprsrrrrr/Ks2			r/c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�TestImplementscCsddlm}|SrC)r$rE)rrErrrr1�szTestImplements._getTargetClasscOs|��||�Sr(r2r3rrrr6�szTestImplements._makeOnecCsH|��}|�|jd�|�|jd�|�|jd�|�t|j�g�dS)Nr�?)r6r�inherit�declaredrr7r8�rrFrrrr;�s
z!TestImplements.test_ctor_no_basescCs"|��}d|_|�t|�d�dS)NZTestingz<implementedBy Testing>)r6rr�reprrxrrr�
test___repr__szTestImplements.test___repr__cCs,ddlm}|��}|�|��|df�dS)Nr��
implementedByr()r$r|r6r�
__reduce__)rr|rFrrr�test___reduce__szTestImplements.test___reduce__cCs�ddlm}Gdd�dt�}Gdd�dt�}ddlm}|d�}|�||�||��|�t||��t||���|�||�dk�|�d||�k�|�||�||�k�|�||�|k�|�||�||�k�|�||�|k�|�||�|k�dS)	Nrr{c@seZdZdS)z#TestImplements.test_sort.<locals>.ANr!rrrr�A
src@seZdZdS)z#TestImplements.test_sort.<locals>.BNr!rrrr�Bsr�r=r?)r$r|r%r@r>r�hashrR)rr|rr�r>r?rrr�	test_sortszTestImplements.test_sortcCs�Gdd�dt�}ddlm}Gdd�dt�}Gdd�dt�}||�}||�}||�}|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�dS)	Nc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
z1TestImplements.test_proxy_equality.<locals>.ProxycSs
||_dSr(�Z_wrapped)r�wrappedrrr�__init__!sz:TestImplements.test_proxy_equality.<locals>.Proxy.__init__cSs
t��dSr(r)�r�namerrr�__getattr__$sz=TestImplements.test_proxy_equality.<locals>.Proxy.__getattr__cSs
|j|kSr(r��rrrrrr�__eq__'sz8TestImplements.test_proxy_equality.<locals>.Proxy.__eq__cSs
|j|kSr(r�r�rrr�__ne__*sz8TestImplements.test_proxy_equality.<locals>.Proxy.__ne__N)rrrr�r�r�r�rrrr�Proxy sr�rr{c@seZdZdS)z-TestImplements.test_proxy_equality.<locals>.ANr!rrrrr.src@seZdZdS)z-TestImplements.test_proxy_equality.<locals>.BNr!rrrrr�1sr�)r%r$r|rRrK)rr�r|rr�ZimplementedByAZimplementedByB�proxyrrr�test_proxy_equalitys 
z"TestImplements.test_proxy_equalityN)
rrrr1r6r;rzr~r�r�rrrrrt�srtc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS) �Test_implementedByFallbackcOsddlm}|||�S)Nr��implementedByFallback)r$r�)rr4r5r�rrr�_callFUTIsz#Test_implementedByFallback._callFUTcCs6Gdd�dt�}|�}d|_|�t|�|��g�dS)Nc@seZdZdZdS)z]Test_implementedByFallback.test_dictless_wo_existing_Implements_wo_registrations.<locals>.Foo��__implemented__N�rrr�	__slots__rrrrr"Nsr")r%r�rr7r��rr"r rrr�5test_dictless_wo_existing_Implements_wo_registrationsMszPTest_implementedByFallback.test_dictless_wo_existing_Implements_wo_registrationscCs*Gdd�dt�}|�}|�t|j|�dS)Nc@s.eZdZdd�Zdd�Zeee�Zdd�ZdS)zhTest_implementedByFallback.test_dictless_wo_existing_Implements_cant_assign___implemented__.<locals>.FoocSs
t��dSr(r)�rrrr�	_get_implVszrTest_implementedByFallback.test_dictless_wo_existing_Implements_cant_assign___implemented__.<locals>.Foo._get_implcSst�dSr()r)r�valrrr�	_set_implXszrTest_implementedByFallback.test_dictless_wo_existing_Implements_cant_assign___implemented__.<locals>.Foo._set_implcSs
t��dSr(r)r�rrr�__call__[szqTest_implementedByFallback.test_dictless_wo_existing_Implements_cant_assign___implemented__.<locals>.Foo.__call__N)rrrr�r��propertyr�r�rrrrr"Us
r"�r%�assertRaisesrr�r�rrr�@test_dictless_wo_existing_Implements_cant_assign___implemented__Ts	z[Test_implementedByFallback.test_dictless_wo_existing_Implements_cant_assign___implemented__c	Csdddlm}Gdd�dt�}|�}d|_t�}t|d��"}|||<|�|�|�|k�W5QRXdS)Nr��declarationsc@seZdZdZdS)z\Test_implementedByFallback.test_dictless_wo_existing_Implements_w_registrations.<locals>.Foor�Nr�rrrrr"csr"�#BuiltinImplementationSpecifications)�zope.interfacer�r%r��_MonkeyDictrRr�)rr�r"r Zreg�specsrrr�4test_dictless_wo_existing_Implements_w_registrationsas�zOTest_implementedByFallback.test_dictless_wo_existing_Implements_w_registrationscCsFddlm}|�}Gdd�dt�}|�}||_|�|�|�|k�dS)NrrDc@seZdZdZdS)zKTest_implementedByFallback.test_dictless_w_existing_Implements.<locals>.Foor�Nr�rrrrr"psr")r$rEr%r�rRr�)rrErFr"r rrr�#test_dictless_w_existing_Implementsmsz>Test_implementedByFallback.test_dictless_w_existing_ImplementscCsNddlm}Gdd�dt�}|�}|d�}|f|_|�t|�|��|g�dS)Nrr=c@seZdZdZdS)zOTest_implementedByFallback.test_dictless_w_existing_not_Implements.<locals>.Foor�Nr�rrrrr"xsr"r?)r@r>r%r�rr7r�)rr>r"r r?rrr�'test_dictless_w_existing_not_ImplementsvszBTest_implementedByFallback.test_dictless_w_existing_not_Implementscs>ddlm}|��G�fdd�dt�}|�|�|��k�dS)NrrDcseZdZ�ZdS)zJTest_implementedByFallback.test_w_existing_attr_as_Implements.<locals>.FooN�rrrr�r�rFrrr"�sr"�r$rEr%rRr��rrEr"rr�r�"test_w_existing_attr_as_Implementssz=Test_implementedByFallback.test_w_existing_attr_as_Implementsc	Cs�ddlm}ddlm}ddlm}t|d���}|�t|�	t
��g�|�t|�	t��g�|�t|�	t��g�t
ttfD]6}||}|�t
||��|�t|�d||jf�q|W5QRXdS)Nrr�rD)�	_BUILTINSr�z<implementedBy %s.%s>)r�r�r$rEr
r�r�rr7r��tuple�dictrRriryr)rr�rEr�r��typ�specrrr�test_builtins_added_to_cache�s$�
��z7Test_implementedByFallback.test_builtins_added_to_cachec	Cs�ddlm}t�t�t�}}}t|d��Z}||t<||t<||t<|�|�t�|k�|�|�t�|k�|�|�t�|k�W5QRXdS)Nrr�r�)	r�r�r%r�r�r7r�rRr�)rr�Zt_specZl_specZd_specr�rrr�test_builtins_w_existing_cache�s�z9Test_implementedByFallback.test_builtins_w_existing_cachecCs(Gdd�d�}|�t|�|��g�dS)Nc@seZdZdS)zITest_implementedByFallback.test_oldstyle_class_no_assertions.<locals>.FooNr!rrrrr"�sr")rr7r��rr"rrr�!test_oldstyle_class_no_assertions�sz<Test_implementedByFallback.test_oldstyle_class_no_assertionscCs*Gdd�dt�}|�t|�|��g�dS)Nc@seZdZdS)z:Test_implementedByFallback.test_no_assertions.<locals>.FooNr!rrrrr"�sr"�r%rr7r�r�rrr�test_no_assertions�sz-Test_implementedByFallback.test_no_assertionscCs*Gdd�dt�}|�}|�t|j|�dS)Nc@seZdZdZdS)zHTest_implementedByFallback.test_w_None_no_bases_not_factory.<locals>.FooNr�rrrrr"�sr"r�r�rrr� test_w_None_no_bases_not_factory�sz;Test_implementedByFallback.test_w_None_no_bases_not_factorycCs�ddlm}Gdd�dt�}|�}d|_|�|�}|�|jd�|�|j|k�|�|j|k�|�|j	|k�|�
d|jk�dS)Nr)�objectSpecificationDescriptorc@seZdZdZdd�ZdS)zFTest_implementedByFallback.test_w_None_no_bases_w_factory.<locals>.FooNcSs
t��dSr(r)r�rrrr��szOTest_implementedByFallback.test_w_None_no_bases_w_factory.<locals>.Foo.__call__)rrrr�r�rrrrr"�sr"r z*zope.interface.tests.test_declarations.foo�__provides__)r$r�r%rr�rrRrvr��__providedBy__rKrL)rr�r"r r�rrr�test_w_None_no_bases_w_factory�s
�z9Test_implementedByFallback.test_w_None_no_bases_w_factorycCs�ddlm}Gdd�dt�}|�|�}|�|jd�|�|j|k�|�|j|k�|�t	|j
|��|�t	|j|��|�|j|j
�dS)Nr��
ClassProvidesc@seZdZdZdS)zDTest_implementedByFallback.test_w_None_no_bases_w_class.<locals>.FooNr�rrrrr"�sr"�*zope.interface.tests.test_declarations.Foo)r$r�r%r�rrrRrvr�rir�r�)rr�r"r�rrr�test_w_None_no_bases_w_class�s
�z7Test_implementedByFallback.test_w_None_no_bases_w_classcs>ddlm}|��G�fdd�dt�}|�|�|��k�dS)NrrDcseZdZ�ZdS)zBTest_implementedByFallback.test_w_existing_Implements.<locals>.FooNr�rr�rrr"�sr"r�r�rr�r�test_w_existing_Implements�sz5Test_implementedByFallback.test_w_existing_ImplementsN)rrrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�Gs
		
r�c@seZdZdd�Zdd�ZdS)�Test_implementedBycOsddlm}|||�S)Nrr{)r$r|)rr4r5r|rrrr��szTest_implementedBy._callFUTcCsVddlm}ddlm}zddl}Wn tk
rD|�||�YnX|�||�dS)Nrr�r{)r$r�r|�-zope.interface._zope_interface_coptimizations�ImportError�assertIs�assertIsNot)rr�r|�zoperrr�test_optimizations�sz%Test_implementedBy.test_optimizationsN�rrrr�r�rrrrr��sr�c@s$eZdZdd�Zdd�Zdd�ZdS)�Test_classImplementsOnlycOsddlm}|||�S)Nr)�classImplementsOnly)r$r�)rr4r5r�rrrr��sz!Test_classImplementsOnly._callFUTcCs�ddlm}ddlm}Gdd�dt�}|d�}|�||�|j}|�|jd�|�	|j
dk�|�	|j|k�|�	t|j|��|�	t|j
|��|�|j
|j�dS)Nrr�r=c@seZdZdS)z6Test_classImplementsOnly.test_no_existing.<locals>.FooNr!rrrrr"�sr"r?r��r$r�r@r>r%r�r�rrrRrvrir�r�)rr�r>r"Zifoor�rrr�test_no_existing�s�z)Test_classImplementsOnly.test_no_existingcs�ddlm}ddlm}|d�}|d�}||��|f�_G�fdd�dt�}|�_|�||�|�|j	�k�|�
�jd�|�
�j|f�dS)NrrDr=r?rXcseZdZ�ZdS)z@Test_classImplementsOnly.test_w_existing_Implements.<locals>.FooNr�rr�rrr"	sr"�r$rEr@r>rwr%rvr�rRr�r�rrEr>r?rXr"rr�rr�sz3Test_classImplementsOnly.test_w_existing_ImplementsN)rrrr�r�r�rrrrr��sr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�Test_classImplementscOsddlm}|||�S)Nr��classImplements)r$r�)rr4r5r�rrrr�szTest_classImplements._callFUTcCs�ddlm}ddlm}Gdd�dt�}|d�}|�||�|j}|�|jd�|�	|j
|k�|�	|j|k�|�	t|j|��|�	t|j
|��|�|j
|j�dS)Nrr�r=c@seZdZdS)z2Test_classImplements.test_no_existing.<locals>.FooNr!rrrrr"sr"r?r�r�)rr�r>r"r?r�rrrr�s�z%Test_classImplements.test_no_existingcs�ddlm}ddlm}|d�}|d�}||��|f�_G�fdd�dt�}|�_|�||�|�|j	�k�|�
�j|�|�
�j||f�dS)NrrDr=r?rXcseZdZ�ZdS)z<Test_classImplements.test_w_existing_Implements.<locals>.FooNr�rr�rrr"0sr"r�r�rr�rr�)sz/Test_classImplements.test_w_existing_Implementsc	s�ddlm}ddlm}|d�}|d�}|d|�}||��||��|f�_G�fdd�dt�}G�fd	d
�d
t�}G�fdd�d||�}|�_|�||�|�|j	�k�|�
�j|�|�
�j||f�|�
�j||�f�dS)
NrrDr=r?rXrqcseZdZ�ZdS)zFTest_classImplements.test_w_existing_Implements_w_bases.<locals>.Base1Nr�r��b_implrr�Base1Bsr�cseZdZ�ZdS)zFTest_classImplements.test_w_existing_Implements_w_bases.<locals>.Base2Nr�rr�rr�Base2Dsr�cseZdZ�ZdS)zDTest_classImplements.test_w_existing_Implements_w_bases.<locals>.FooNr�rr�rrr"Fsr")r$rEr@r>rwr%rvr�rRr�rr8)	rrEr>r?rXrqr�r�r"r)r�rFr�"test_w_existing_Implements_w_bases9s"
z7Test_classImplements.test_w_existing_Implements_w_basesN)rrrr�r�r�r�rrrrr�sr�c@seZdZdd�Zdd�ZdS)�Test__implements_advicecOsddlm}|||�S)Nr)�_implements_advice)r$r�)rr4r5r�rrrr�Ssz Test__implements_advice._callFUTcs�ddlm�ddlm}ddlm}|d��G��fdd�dt�}|�|�|�d|jk�|�	t
|j|��|�t
|j��g�dS)	Nrr�rDr=r?cseZdZ�f�fZdS)z@Test__implements_advice.test_no_existing_implements.<locals>.FooN)rrr�__implements_advice_data__r�r?r�rrr"\sr"r�)r$r�rEr@r>r%r�rKrLrRrir�rr7)rrEr>r"rr�r�test_no_existing_implementsWs
z3Test__implements_advice.test_no_existing_implementsN)rrrr�r�rrrrr�Qsr�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�Test_implementercCsddlm}|S)Nr��implementer)r$r�)rr�rrrr1fsz Test_implementer._getTargetClasscOs|��||�Sr(r2r3rrrr6jszTest_implementer._makeOnecCs�ddlm}ddlm}|d�}Gdd�d�}|�|�}||�}|�||k�|j}|�|jd�|�|j	|k�|�|j|k�|�t
|j|��|�t
|j|��|�|j|j�dS)Nrr�r=r?c@seZdZdS)z1Test_implementer.test_oldstyle_class.<locals>.FooNr!rrrrr"rsr"r�)
r$r�r@r>r6rRr�rrrvrir�r��rr�r>r?r"�	decorator�returnedr�rrr�test_oldstyle_classms 
�z$Test_implementer.test_oldstyle_classcCs�ddlm}ddlm}|d�}Gdd�dt�}|�|�}||�}|�||k�|j}|�|j	d�|�|j
|k�|�|j|k�|�t|j|��|�t|j
|��|�|j
|j�dS)Nrr�r=r?c@seZdZdS)z1Test_implementer.test_newstyle_class.<locals>.FooNr!rrrrr"�sr"r�)r$r�r@r>r%r6rRr�rrrvrir�r�r�rrr�test_newstyle_class�s 
�z$Test_implementer.test_newstyle_classcCs2ddlm}|d�}|�|�}|�t|t��dSr<)r@r>r6r�rr%)rr>r?r�rrr� test_nonclass_cannot_assign_attr�s
z1Test_implementer.test_nonclass_cannot_assign_attrcCs�ddlm}|d�}Gdd�dt�}|�}|�|�}||�}|�||k�|j}|�|jd�|�|jdk�|�|j|k�dS)Nrr=r?c@seZdZdS)z;Test_implementer.test_nonclass_can_assign_attr.<locals>.FooNr!rrrrr"�sr"z(zope.interface.tests.test_declarations.?)	r@r>r%r6rRr�rrrv)rr>r?r"r r�r�r�rrr�test_nonclass_can_assign_attr�s
z.Test_implementer.test_nonclass_can_assign_attrN)	rrrr1r6r�r�r�r�rrrrr�dsr�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�Test_implementer_onlycCsddlm}|S)Nr)�implementer_only)r$r�)rr�rrrr1�sz%Test_implementer_only._getTargetClasscOs|��||�Sr(r2r3rrrr6�szTest_implementer_only._makeOnecCs8ddlm}|d�}|�|�}dd�}|�t||�dS)Nrr=r?cSs
t��dSr(r)rrrr�	_function�sz6Test_implementer_only.test_function.<locals>._function)r@r>r6r��
ValueError)rr>r?r�r�rrrr-�s

z#Test_implementer_only.test_functioncCs@ddlm}|d�}|�|�}Gdd�d�}|�t||j�dS)Nrr=r?c@seZdZdd�ZdS)z.Test_implementer_only.test_method.<locals>.BarcSs
t��dSr(r)rrrr�_method�sz6Test_implementer_only.test_method.<locals>.Bar._methodN)rrrr�rrrr�Bar�sr�)r@r>r6r�r�r�)rr>r?r�r�rrr�test_method�s

z!Test_implementer_only.test_methodc	s�ddlm}ddlm}|d�}|d�}||��G�fdd�d�}|�|�}||�}|�||k�|j}|�|jd�|�|j	dk�|�|j|k�dS)	NrrDr=r?rXcseZdZ�ZdS)z6Test_implementer_only.test_oldstyle_class.<locals>.FooNr�r�Zold_specrrr"�sr"ru)
r$rEr@r>r6rRr�rrrv�	rrEr>r?rXr"r�r�r�rr�rr��s
z)Test_implementer_only.test_oldstyle_classc	s�ddlm}ddlm}|d�}|d�}||��G�fdd�dt�}|�|�}||�}|�||k�|j}|�|j	d�|�|j
dk�|�|j|k�dS)	NrrDr=r?rXcseZdZ�ZdS)z6Test_implementer_only.test_newstyle_class.<locals>.FooNr�rr�rrr"�sr"ru)r$rEr@r>r%r6rRr�rrrvr�rr�rr��s
z)Test_implementer_only.test_newstyle_classN)	rrrr1r6r-r�r�r�rrrrr��s	r�c@seZdZdd�Zdd�ZdS)�Test_implementsOnlyc	Cs�ddl}ddlm}ddlm}ddlm}|d�}||d�}i}d�dg�}|jd	d
��~}	|�	�zt
|||�Wn tk
r�|�|d�Yn@X|r�|�
d�|d
}
|
j}|�t|�|g�|�t|	�d�W5QRXdS)Nr��implementsOnlyrr=r?)r�r?�
z*class Foo(object):    implementsOnly(IFoo)TrzMust be Python 3rr")r	r$r�r
rr@r>�joinrrr
rrRrr�rr7r)rr	r�rr>r?rr�CODErr"r�rrr�test_simple�s0��
zTest_implementsOnly.test_simplecCs�ddlm}ddlm}ddlm}|d�}|d�}||||d�}i}d�d	d
dg�}|�|||�r�|d}	|	j}
|�t	|
�|g�dS)
Nr��
implementsr�r=r?rX)r�r�r?rXr��class Foo(object):�    implements(IFoo)z'class Bar(Foo):    implementsOnly(IBar)r�)
r$r�r�r@r>r�rr�rr7)rr�r�r>r?rXrrr�r�r�rrr�#test_called_once_from_class_w_basess(��z7Test_implementsOnly.test_called_once_from_class_w_basesN)rrrr�r�rrrrr��sr�c@s$eZdZdd�Zdd�Zdd�ZdS)�Test_implementsc
	Cs�ddl}ddlm}ddlm}|d�}||d�}i}d�ddg�}|�|||d	�r�|d
}|jdd��*}	|��|�	t
|�|�t|	�d�W5QRXdS)
Nrr�r=r?�r�r?r��
def foo():r�Fr Tr)
r	r$r�r@r>r�rrrr�rrr)
rr	r�r>r?rrr�r rrrr�test_called_from_functions 
�z)Test_implements.test_called_from_functionc	Cs�ddl}ddlm}ddlm}ddlm}|d�}|d�}|||d�}i}d�d	d
dg�}	|jdd
��R}
|�	�zt
|	||�Wn(tk
r�|s�|�t
|
�d�YnX|�d�W5QRXdS)Nrr�r=rr?rX)r�r?rXr�r�r�z    implements(IBar)Trr)r	r$r�r@r>r
rr�rrr
rrrr)rr	r�r>rr?rXrrr�rrrr�test_called_twice_from_class/s*�z,Test_implements.test_called_twice_from_classc	Csnddlm}ddlm}|d�}||d�}i}d�ddg�}|�|||�rj|d	}|j}|�t|�|g�dS)
Nrr�r=r?rr�r�r�r")	r$r�r@r>r�rr�rr7)	rr�r>r?rrr�r"r�rrr�test_called_once_from_classGs
�z+Test_implements.test_called_once_from_classN�rrrrrrrrrrr�sr�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ProvidesClassTestscCsddlm}|S)Nr��
ProvidesClass)r$r)rrrrrr1Ysz"ProvidesClassTests._getTargetClasscOs|��||�Sr(r2r3rrrr6]szProvidesClassTests._makeOnecCsFddlm}|d�}Gdd�dt�}|�||�}|�t|�|g�dS)Nrr=r?c@seZdZdS)z?ProvidesClassTests.test_simple_class_one_interface.<locals>.FooNr!rrrrr"csr")r@r>r%r6rr7�rr>r?r"r�rrr�test_simple_class_one_interface`s
z2ProvidesClassTests.test_simple_class_one_interfacecCsjddlm}ddlm}|d�}Gdd�dt�}|�||�}|��\}}|�||k�|�|||f�dS)Nr��Providesr=r?c@seZdZdS)z/ProvidesClassTests.test___reduce__.<locals>.FooNr!rrrrr"lsr")	r$rr@r>r%r6r}rRr)rrr>r?r"r��klassr4rrrr~hsz"ProvidesClassTests.test___reduce__cCsJddlm}|d�}Gdd�dt�}|�||�}||_|�|j|k�dS)Nrr=r?c@seZdZdS)z2ProvidesClassTests.test___get___class.<locals>.FooNr!rrrrr"vsr"�r@r>r%r6r�rRr	rrr�test___get___classssz%ProvidesClassTests.test___get___classcsRddlm}|d�}Gdd�dt��|��|�}|�_�fdd�}|�t|�dS)Nrr=r?c@seZdZdS)z5ProvidesClassTests.test___get___instance.<locals>.FooNr!rrrrr"sr"cs��}|jSr()r�)r �r"rr�_test�sz7ProvidesClassTests.test___get___instance.<locals>._test)r@r>r%r6r�r��AttributeError)rr>r?r�rrrr�test___get___instance|sz(ProvidesClassTests.test___get___instanceN)	rrrr1r6r
r~rrrrrrrWs	rc@s$eZdZdd�Zdd�Zdd�ZdS)�
Test_ProvidescOsddlm}|||�S)Nrr)r$r)rr4r5rrrrr��szTest_Provides._callFUTc	Cs�ddlm}ddlm}|d�}i}Gdd�dt�}t||d��|�||�}W5QRX|�t|�|g�|�	|||f|k�dS)Nrr�r=r?c@seZdZdS)z.Test_Provides.test_no_cached_spec.<locals>.FooNr!rrrrr"�sr"�ZInstanceDeclarations)
r�r�r@r>r%�_Monkeyr�rr7rR)rr�r>r?�cacher"r�rrr�test_no_cached_spec�sz!Test_Provides.test_no_cached_specc	Csxddlm}ddlm}|d�}t�}Gdd�dt�}||f|i}t||d��|�||�}W5QRX|�||k�dS)Nrr�r=r?c@seZdZdS)z-Test_Provides.test_w_cached_spec.<locals>.FooNr!rrrrr"�sr"r)r�r�r@r>r%rr�rR)rr�r>r?Zpriorr"rr�rrr�test_w_cached_spec�sz Test_Provides.test_w_cached_specN)rrrr�rrrrrrr�src@s8eZdZdd�Zdd�Zdd�Zedd��Zd	d
�ZdS)�Test_directlyProvidescOsddlm}|||�S)Nr��directlyProvides)r$r)rr4r5rrrrr��szTest_directlyProvides._callFUTcCslddlm}ddlm}|d�}Gdd�dt�}|�}|�||�|�t|j|��|�	t
|j�|g�dS)Nrrr=r?c@seZdZdS)z7Test_directlyProvides.test_w_normal_object.<locals>.FooNr!rrrrr"�sr"�r$rr@r>r%r�rRrir�rr7�rrr>r?r"�objrrr�test_w_normal_object�sz*Test_directlyProvides.test_w_normal_objectcCsfddlm}ddlm}|d�}Gdd�dt�}|�||�|�t|j|��|�	t
|j�|g�dS)Nrr�r=r?c@seZdZdS)z/Test_directlyProvides.test_w_class.<locals>.FooNr!rrrrr"�sr")r$r�r@r>r%r�rRrir�rr7�rr�r>r?r"rrr�test_w_class�sz"Test_directlyProvides.test_w_classcsTddlm}|d�}Gdd�dt��G�fdd�dt�}|�}|�t|j||�dS)Nrr=r?c@seZdZdd�ZdS)zNTest_directlyProvides.test_w_non_descriptor_aware_metaclass.<locals>.MetaClasscSs|dkr|St�||�S�N�	__class__)�type�__getattribute__)�clsr�rrrr&�sz_Test_directlyProvides.test_w_non_descriptor_aware_metaclass.<locals>.MetaClass.__getattribute__N)rrrr&rrrr�	MetaClass�sr(cseZdZ�ZdS)zHTest_directlyProvides.test_w_non_descriptor_aware_metaclass.<locals>.FooN)rrrZ
__metaclass__r�r(rrr"�sr")r@r>r%r%r�rr��rr>r?r"rrr)r�%test_w_non_descriptor_aware_metaclass�s	z;Test_directlyProvides.test_w_non_descriptor_aware_metaclasscsxddlm}ddlm}|d�}i�G�fdd�dt�}|�}|�||�|�t�d|��|�t	�d�|g�dS)Nrrr=r?cs eZdZdd�Z�fdd�ZdS)z:Test_directlyProvides.test_w_classless_object.<locals>.FoocSs|dkrdSt|��dSr#r)r�rrrr&�szKTest_directlyProvides.test_w_classless_object.<locals>.Foo.__getattribute__cs|�|<dSr(r�rr��value�Zthe_dictrr�__setattr__�szFTest_directlyProvides.test_w_classless_object.<locals>.Foo.__setattr__N�rrrr&r/rr.rrr"�sr"r�)
r$rr@r>r%r�rRrirr7rrr.r�test_w_classless_object�sz-Test_directlyProvides.test_w_classless_objectN)	rrrr�r r"rr+r1rrrrr�s

rc@s$eZdZdd�Zdd�Zdd�ZdS)�Test_alsoProvidescOsddlm}|||�S)Nr)�alsoProvides)r$r3)rr4r5r3rrrr��szTest_alsoProvides._callFUTcCslddlm}ddlm}|d�}Gdd�dt�}|�}|�||�|�t|j|��|�	t
|j�|g�dS)Nrrr=r?c@seZdZdS)z8Test_alsoProvides.test_wo_existing_provides.<locals>.FooNr!rrrrr"�sr"rrrrr�test_wo_existing_provides�sz+Test_alsoProvides.test_wo_existing_providescCs�ddlm}ddlm}ddlm}|d�}|d�}Gdd�dt�}|�}|||�|�||�|�t|j	|��|�
t|j	�||g�dS)	Nrrrr=r?rXc@seZdZdS)z7Test_alsoProvides.test_w_existing_provides.<locals>.FooNr!rrrrr"sr")r$rrr@r>r%r�rRrir�rr7)rrrr>r?rXr"rrrr�test_w_existing_provides�s
z*Test_alsoProvides.test_w_existing_providesN)rrrr�r4r5rrrrr2�sr2c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�Test_noLongerProvidescOsddlm}|||�S)Nr)�noLongerProvides)r$r7)rr4r5r7rrrr�szTest_noLongerProvides._callFUTcCsLddlm}|d�}Gdd�dt�}|�}|�||�|�t|j�g�dS)Nrr=r?c@seZdZdS)z<Test_noLongerProvides.test_wo_existing_provides.<locals>.FooNr!rrrrr"sr")r@r>r%r�rr7r�r*rrrr4sz/Test_noLongerProvides.test_wo_existing_providescCsbddlm}ddlm}|d�}Gdd�dt�}|�}|||�|�||�|�t|j�g�dS)Nrrr=r?c@seZdZdS)z?Test_noLongerProvides.test_w_existing_provides_hit.<locals>.FooNr!rrrrr"sr"�	r$rr@r>r%r�rr7r�)rrr>r?r"rrrr�test_w_existing_provides_hits
z2Test_noLongerProvides.test_w_existing_provides_hitcCslddlm}ddlm}|d�}|d�}Gdd�dt�}|�}|||�|�||�|�t|j�|g�dS)Nrrr=r?rXc@seZdZdS)z@Test_noLongerProvides.test_w_existing_provides_miss.<locals>.FooNr!rrrrr"(sr"r8)rrr>r?rXr"rrrr�test_w_existing_provides_miss#s
z3Test_noLongerProvides.test_w_existing_provides_misscCsTddlm}ddlm}|d�}||�Gdd�dt��}|�}|�t|j||�dS)Nrr�r=r?c@seZdZdS)zDTest_noLongerProvides.test_w_iface_implemented_by_class.<locals>.FooNr!rrrrr"3sr")r$r�r@r>r%r�r�r�)rr�r>r?r"rrrr�!test_w_iface_implemented_by_class/sz7Test_noLongerProvides.test_w_iface_implemented_by_classN)rrrr�r4r9r:r;rrrrr6	s
	r6c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ClassProvidesBaseFallbackTestscCsddlm}|S�Nr)�ClassProvidesBaseFallback)r$r>)rr>rrrr1<sz.ClassProvidesBaseFallbackTests._getTargetClasscCsGdd�d|���}|||�S)Nc@seZdZdd�ZdS)z8ClassProvidesBaseFallbackTests._makeOne.<locals>.DerivedcSs||_||_dSr()�_clsZ_implements)r�k�irrrr�DszAClassProvidesBaseFallbackTests._makeOne.<locals>.Derived.__init__N)rrrr�rrrr�DerivedCsrBr2)rr
r�rBrrrr6@sz'ClassProvidesBaseFallbackTests._makeOnecCsJddlm}|d�}Gdd�dt�}|�||�}|_|�|j|k�dS)Nrr=r?c@seZdZdS)zGClassProvidesBaseFallbackTests.test_w_same_class_via_class.<locals>.FooNr!rrrrr"Lsr"r)rr>r?r"�cpbprrr�test_w_same_class_via_classIs
z:ClassProvidesBaseFallbackTests.test_w_same_class_via_classcCsPddlm}|d�}Gdd�dt�}|�}|�||�}|_|�|j|k�dS)Nrr=r?c@seZdZdS)zJClassProvidesBaseFallbackTests.test_w_same_class_via_instance.<locals>.FooNr!rrrrr"Tsr"r)rr>r?r"r rCrrr�test_w_same_class_via_instanceQsz=ClassProvidesBaseFallbackTests.test_w_same_class_via_instancecCspddlm}|d�}Gdd�dt�}Gdd�d|�}|�}|�||�}|_|�tt|d�|�tt|d�dS)	Nrr=r?c@seZdZdS)zBClassProvidesBaseFallbackTests.test_w_different_class.<locals>.FooNr!rrrrr"]sr"c@seZdZdS)zBClassProvidesBaseFallbackTests.test_w_different_class.<locals>.BarNr!rrrrr�_sr�r�)r@r>r%r6r�r�r�getattr)rr>r?r"r�ZbarrCrrr�test_w_different_classZsz5ClassProvidesBaseFallbackTests.test_w_different_classN)rrrr1r6rDrErGrrrrr<:s
		r<c@seZdZdd�Zdd�ZdS)�ClassProvidesBaseTestscCsddlm}|S)Nr)�ClassProvidesBase)r$rI)rrIrrrr1jsz&ClassProvidesBaseTests._getTargetClasscCsRddlm}zddl}Wn$tk
r<|�|��|�YnX|�|��|�dSr=)r$r>r�r�r�r1r�)rr>r�rrrr�nsz)ClassProvidesBaseTests.test_optimizationsN�rrrr1r�rrrrrHgsrHc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ClassProvidesTestscCsddlm}|S)Nrr�)r$r�)rr�rrrr1zsz"ClassProvidesTests._getTargetClasscOs|��||�Sr(r2r3rrrr6~szClassProvidesTests._makeOnecCs�ddlm}ddlm}|d�}|d�}||�Gdd�dt��}|�|t|�|�}|_|�|j|k�|�	t
|�j�|g�dS)Nrr�r=r?rXc@seZdZdS)z7ClassProvidesTests.test_w_simple_metaclass.<locals>.FooNr!rrrrr"�sr")r$r�r@r>r%r6r%r�rRrr7�rr�r>r?rXr"�cprrr�test_w_simple_metaclass�sz*ClassProvidesTests.test_w_simple_metaclasscCs~ddlm}ddlm}|d�}|d�}||�Gdd�dt��}|�|t|�|�}|_|�|�	�|�
�|t|�|ff�dS)Nrr�r=r?rXc@seZdZdS)z/ClassProvidesTests.test___reduce__.<locals>.FooNr!rrrrr"�sr")r$r�r@r>r%r6r%r�rr}r1rLrrrr~�s
�z"ClassProvidesTests.test___reduce__N)rrrr1r6rNr~rrrrrKxsrKc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�Test_directlyProvidedBycOsddlm}|||�S)Nr)�directlyProvidedBy)r$rP)rr4r5rPrrrr��sz Test_directlyProvidedBy._callFUTcCs0Gdd�dt�}|�}|�t|�|��g�dS)Nc@seZdZdS)zNTest_directlyProvidedBy.test_wo_declarations_in_class_or_instance.<locals>.FooNr!rrrrr"�sr"r�r�rrr�)test_wo_declarations_in_class_or_instance�szATest_directlyProvidedBy.test_wo_declarations_in_class_or_instancecCsXddlm}ddlm}|d�}||�Gdd�dt��}|�}|�t|�|��g�dS)Nrr�r=r?c@seZdZdS)zRTest_directlyProvidedBy.test_w_declarations_in_class_but_not_instance.<locals>.FooNr!rrrrr"�sr")r$r�r@r>r%rr7r�)rr�r>r?r"r rrr�-test_w_declarations_in_class_but_not_instance�szETest_directlyProvidedBy.test_w_declarations_in_class_but_not_instancecCs\ddlm}ddlm}|d�}Gdd�dt�}|�}|||�|�t|�|��|g�dS)Nrrr=r?c@seZdZdS)zRTest_directlyProvidedBy.test_w_declarations_in_instance_but_not_class.<locals>.FooNr!rrrrr"�sr")r$rr@r>r%rr7r�)rrr>r?r"r rrr�-test_w_declarations_in_instance_but_not_class�s
zETest_directlyProvidedBy.test_w_declarations_in_instance_but_not_classcCsxddlm}ddlm}ddlm}|d�}|d�}||�Gdd�dt��}|�}|||�|�t|�|��|g�dS)	Nrrr�r=r?rXc@seZdZdS)zNTest_directlyProvidedBy.test_w_declarations_in_instance_and_class.<locals>.FooNr!rrrrr"�sr")	r$rr�r@r>r%rr7r�)rrr�r>r?rXr"r rrr�)test_w_declarations_in_instance_and_class�s
zATest_directlyProvidedBy.test_w_declarations_in_instance_and_classN)rrrr�rQrRrSrTrrrrrO�s


rOc@s$eZdZdd�Zdd�Zdd�ZdS)�Test_classProvidesc	Cs�ddl}ddlm}ddlm}ddlm}|d�}||d�}i}d�dd	g�}t|||�|d
}	|j	dd��.}
|�
�|�t|	�|s�|�
t|
�d�W5QRXdS)
Nr��
classProvidesr=rr?�rWr?r�r�    classProvides(IFoo)r Tr)r	r$rWr@r>r
rr�r
rrr�rrr)rr	rWr>rr?rrr�r rrrrr�s$
�z,Test_classProvides.test_called_from_functionc	Cs�ddl}ddlm}ddlm}ddlm}|d�}|d�}|||d�}i}d�d	d
dg�}	|jdd
��R}
|�	�zt
|	||�Wn(tk
r�|s�|�t
|
�d�YnX|�d�W5QRXdS)NrrVr=rr?rX)rWr?rXr�r�rYz    classProvides(IBar)Trr)r	r$rWr@r>r
rr�rrr
rrrr)rr	rWr>rr?rXrrr�rrrrr�s*�z/Test_classProvides.test_called_twice_from_classc	Csnddlm}ddlm}|d�}||d�}i}d�ddg�}|�|||�rj|d	}|j}|�t|�|g�dS)
NrrVr=r?rXr�r�rYr")	r$rWr@r>r�rr�rr7)	rrWr>r?rrr�r"r�rrrr�s
�z.Test_classProvides.test_called_once_from_classNrrrrrrU�srUc@s$eZdZdd�Zdd�Zdd�ZdS)�
Test_providercCsddlm}|S)Nr)�provider)r$r[)rr[rrrr1
szTest_provider._getTargetClasscOs|��||�Sr(r2r3rrrr6szTest_provider._makeOnecCsdddlm}ddlm}|d�}|�|�Gdd�dt��}|�t|j|��|�	t
|j�|g�dS)Nrr�r=r?c@seZdZdS)z'Test_provider.test_w_class.<locals>.FooNr!rrrrr"sr")r$r�r@r>r6r%rRrir�rr7r!rrrr"szTest_provider.test_w_classN)rrrr1r6r"rrrrrZsrZc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�Test_moduleProvidescCsbddlm}ddlm}|d�}d||d�}i}d�dd	g�}t|||�|d
}|�t|�dS)Nr��moduleProvidesr=r?�zope.interface.tests.foo�rr^r?r�r�    moduleProvides(IFoo)r )r$r^r@r>r�r
r�r)rr^r>r?rrr�r rrrrs��z-Test_moduleProvides.test_called_from_functionc	Csdddlm}ddlm}|d�}d||d�}i}d�dd	g�}|�t��t|||�W5QRXdS)
Nrr]r=r?r_r`r�r�ra�r$r^r@r>r�r�rr
�rr^r>r?rrr�rrr�test_called_from_class-s��z*Test_moduleProvides.test_called_from_classcCs`ddlm}ddlm}|d�}d||d�}d�dg�}t||�|d	}|�t|�|g�dS)
Nrr]r=r?r_r`r��moduleProvides(IFoo)r�)r$r^r@r>r�r
rr7)rr^r>r?rr�r�rrr�"test_called_once_from_module_scope;s��
z6Test_moduleProvides.test_called_once_from_module_scopec	Csbddlm}ddlm}|d�}d||d�}i}d�ddg�}|�t��t||�W5QRXdS)	Nrr]r=r?r_r`r�rerbrcrrr�#test_called_twice_from_module_scopeHs��z7Test_moduleProvides.test_called_twice_from_module_scopeN)rrrrrdrfrgrrrrr\s
r\c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�#Test_getObjectSpecificationFallbackcOsddlm}|||�S)Nr��getObjectSpecificationFallback)r$rj)rr4r5rjrrrr�Ysz,Test_getObjectSpecificationFallback._callFUTcs<i�G�fdd�dt�}|�}|�|�}|�t|�g�dS)Ncs eZdZ�fdd�Zdd�ZdS)zTTest_getObjectSpecificationFallback.test_wo_existing_provides_classless.<locals>.Foocs<|dkrt|��z
�|WStk
r6t|��YnXdSr#)r�KeyErrorr�r.rrr&`s
zeTest_getObjectSpecificationFallback.test_wo_existing_provides_classless.<locals>.Foo.__getattribute__cSs
t��dSr(r)r,rrrr/hsz`Test_getObjectSpecificationFallback.test_wo_existing_provides_classless.<locals>.Foo.__setattr__Nr0rr.rrr"_sr"�r%r�rr7�rr"r r�rr.r�#test_wo_existing_provides_classless]s

zGTest_getObjectSpecificationFallback.test_wo_existing_provides_classlesscCsPddlm}ddlm}|d�}dd�}|||�|�|�}|�||jk�dS)Nrrr=r?cSs
t��dSr(r)rrrrr rszOTest_getObjectSpecificationFallback.test_existing_provides_is_spec.<locals>.foo)r$rr@r>r�rRr�)rrr>r?r r�rrr�test_existing_provides_is_specns

zBTest_getObjectSpecificationFallback.test_existing_provides_is_speccCs.dd�}t�|_|�|�}|�t|�g�dS)NcSs
t��dSr(r)rrrrr yszSTest_getObjectSpecificationFallback.test_existing_provides_is_not_spec.<locals>.foo)r%r�r�rr7)rr r�rrr�"test_existing_provides_is_not_specxs
zFTest_getObjectSpecificationFallback.test_existing_provides_is_not_speccCs`ddlm}ddlm}|d�}Gdd�dt�}|�}|||�|�|�}|�t|�|g�dS)Nrrr=r?c@seZdZdS)zGTest_getObjectSpecificationFallback.test_existing_provides.<locals>.FooNr!rrrrr"�sr")r$rr@r>r%r�rr7)rrr>r?r"r r�rrr�test_existing_providess

z:Test_getObjectSpecificationFallback.test_existing_providescCs^ddlm}ddlm}|d�}||�Gdd�dt��}|�}|�|�}|�t|�|g�dS)Nrr�r=r?c@seZdZdS)zWTest_getObjectSpecificationFallback.test_wo_provides_on_class_w_implements.<locals>.FooNr!rrrrr"�sr")r$r�r@r>r%r�rr7�rr�r>r?r"r r�rrr�&test_wo_provides_on_class_w_implements�s
zJTest_getObjectSpecificationFallback.test_wo_provides_on_class_w_implementscCs4Gdd�dt�}|�}|�|�}|�t|�g�dS)Nc@seZdZdS)zXTest_getObjectSpecificationFallback.test_wo_provides_on_class_wo_implements.<locals>.FooNr!rrrrr"�sr"rlrmrrr�'test_wo_provides_on_class_wo_implements�s
zKTest_getObjectSpecificationFallback.test_wo_provides_on_class_wo_implementsN)
rrrr�rnrorprqrsrtrrrrrhWs
rhc@seZdZdd�Zdd�ZdS)�Test_getObjectSpecificationcOsddlm}|||�S)Nr��getObjectSpecification)r$rw)rr4r5rwrrrr��sz$Test_getObjectSpecification._callFUTcCsVddlm}ddlm}zddl}Wn tk
rD|�||�YnX|�||�dS)Nrrirv)r$rjrwr�r�r�r�)rrjrwr�rrrr��s�
�z.Test_getObjectSpecification.test_optimizationsNr�rrrrru�sruc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�Test_providedByFallbackcOsddlm}|||�S)Nr��providedByFallback)r$rz)rr4r5rzrrrr��sz Test_providedByFallback._callFUTcCs4Gdd�dt�}|�}|�|�}|�t|�g�dS)Nc@seZdZdS)zNTest_providedByFallback.test_wo_providedBy_on_class_wo_implements.<locals>.FooNr!rrrrr"�sr"rlrmrrr�)test_wo_providedBy_on_class_wo_implements�s
zATest_providedByFallback.test_wo_providedBy_on_class_wo_implementscCsbddlm}ddlm}|d�}Gdd�dt�}|�}|||�|_|�|�}|�t|�|g�dS)Nrrr=r?c@seZdZdS)zATest_providedByFallback.test_w_providedBy_valid_spec.<locals>.FooNr!rrrrr"�sr")	r$rr@r>r%r�r�rr7)rrr>r?r"r r�rrr�test_w_providedBy_valid_spec�s
z4Test_providedByFallback.test_w_providedBy_valid_speccCs<Gdd�dt�}|�}t�|_|�|�}|�t|�g�dS)Nc@seZdZdS)zCTest_providedByFallback.test_w_providedBy_invalid_spec.<locals>.FooNr!rrrrr"�sr")r%r�r�rr7rmrrr�test_w_providedBy_invalid_spec�s

z6Test_providedByFallback.test_w_providedBy_invalid_speccCsfddlm}ddlm}|d�}||�Gdd�dt��}|�}t�|_|�|�}|�t|�|g�dS)Nrr�r=r?c@seZdZdS)zVTest_providedByFallback.test_w_providedBy_invalid_spec_class_w_implements.<locals>.FooNr!rrrrr"�sr")	r$r�r@r>r%r�r�rr7rrrrr�1test_w_providedBy_invalid_spec_class_w_implements�s
zITest_providedByFallback.test_w_providedBy_invalid_spec_class_w_implementscCsFGdd�dt�}|�}t�|_t�}|_|�|�}|�||k�dS)Nc@seZdZdS)zcTest_providedByFallback.test_w_providedBy_invalid_spec_w_provides_no_provides_on_class.<locals>.FooNr!rrrrr"�sr"�r%r�r�r�rR�rr"r Zexpectedr�rrr�>test_w_providedBy_invalid_spec_w_provides_no_provides_on_class�s
zVTest_providedByFallback.test_w_providedBy_invalid_spec_w_provides_no_provides_on_classcCsNGdd�dt�}|�}t�|_t�}|_t�|_|�|�}|�||k�dS)Nc@seZdZdS)zeTest_providedByFallback.test_w_providedBy_invalid_spec_w_provides_diff_provides_on_class.<locals>.FooNr!rrrrr"�sr"rr�rrr�@test_w_providedBy_invalid_spec_w_provides_diff_provides_on_class�s
zXTest_providedByFallback.test_w_providedBy_invalid_spec_w_provides_diff_provides_on_classcCstddlm}ddlm}|d�}||�Gdd�dt��}|�}t�|_t�|_|_|�|�}|�t	|�|g�dS)Nrr�r=r?c@seZdZdS)zeTest_providedByFallback.test_w_providedBy_invalid_spec_w_provides_same_provides_on_class.<locals>.FooNr!rrrrr"�sr")
r$r�r@r>r%r�r�r�rr7rrrrr�@test_w_providedBy_invalid_spec_w_provides_same_provides_on_class�s
zXTest_providedByFallback.test_w_providedBy_invalid_spec_w_provides_same_provides_on_classN)rrrr�r{r|r}r~r�r�r�rrrrrx�s	
rxc@seZdZdd�Zdd�ZdS)�Test_providedBycOsddlm}|||�S)Nr��
providedBy)r$r�)rr4r5r�rrrr�szTest_providedBy._callFUTcCsVddlm}ddlm}zddl}Wn tk
rD|�||�YnX|�||�dS)Nrryr�)r$rzr�r�r�r�r�)rrzr�r�rrrr�sz"Test_providedBy.test_optimizationsNr�rrrrr��sr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�*ObjectSpecificationDescriptorFallbackTestscCsddlm}|S�Nr)�%ObjectSpecificationDescriptorFallback)r$r�)rr�rrrr1sz:ObjectSpecificationDescriptorFallbackTests._getTargetClasscOs|��||�Sr(r2r3rrrr6sz3ObjectSpecificationDescriptorFallbackTests._makeOnecCs^ddlm}ddlm}|d�}Gdd�dt�}|||�|_|��|_|�t	|j�|g�dS)Nrrr=r?c@seZdZdS)zOObjectSpecificationDescriptorFallbackTests.test_accessed_via_class.<locals>.FooNr!rrrrr"sr")
r$rr@r>r%r�r6r�rr7)rrr>r?r"rrr�test_accessed_via_classs
zBObjectSpecificationDescriptorFallbackTests.test_accessed_via_classcCs�ddlm}ddlm}ddlm}|d�}|d�}||�Gdd�dt��}|||�|_|��|_|�}|�	t
|j�|g�dS)	Nrr�rr=r?rXc@seZdZdS)zZObjectSpecificationDescriptorFallbackTests.test_accessed_via_inst_wo_provides.<locals>.FooNr!rrrrr"*sr")r$r�rr@r>r%r�r6r�rr7)rr�rr>r?rXr"r rrr�"test_accessed_via_inst_wo_provides$s
zMObjectSpecificationDescriptorFallbackTests.test_accessed_via_inst_wo_providesc
Cs�ddlm}ddlm}ddlm}ddlm}|d�}|d�}|d�}||�Gd	d
�d
t��}|||�|_|��|_	|�}	||	|�|�
t|	j	�||g�dS)Nrrr�rr=r?rXrqc@seZdZdS)zYObjectSpecificationDescriptorFallbackTests.test_accessed_via_inst_w_provides.<locals>.FooNr!rrrrr":sr")r$rr�rr@r>r%r�r6r�rr7)
rrr�rr>r?rXrqr"r rrr�!test_accessed_via_inst_w_provides2s

zLObjectSpecificationDescriptorFallbackTests.test_accessed_via_inst_w_providesN)rrrr1r6r�r�r�rrrrr�s

r�c@seZdZdd�Zdd�ZdS)�"ObjectSpecificationDescriptorTestscCsddlm}|S)Nr)�ObjectSpecificationDescriptor)r$r�)rr�rrrr1Hsz2ObjectSpecificationDescriptorTests._getTargetClasscCsRddlm}zddl}Wn$tk
r<|�|��|�YnX|�|��|�dSr�)r$r�r�r�r�r1r�)rr�r�rrrr�Ls
�

�z5ObjectSpecificationDescriptorTests.test_optimizationsNrJrrrrr�Dsr�c@s$eZdZdd�Zdd�Zdd�ZdS)rcs@�|_t�fdd�|D��|_|��D]\}}t�||�q&dS)Ncsg|]}|t�|�f�qSr)rF)�.0�key��modulerr�
<listcomp>`sz$_Monkey.__init__.<locals>.<listcomp>)r�r��
to_restore�items�setattr)rr�r5r�r-rr�rr�^sz_Monkey.__init__cCs|Sr(rr�rrr�	__enter__dsz_Monkey.__enter__cCs&|j��D]\}}t|j||�q
dSr()r�r�r�r�)r�exc_type�exc_val�exc_tbr�r-rrr�__exit__gsz_Monkey.__exit__N�rrrr�r�r�rrrrr\src@s$eZdZdd�Zdd�Zdd�ZdS)r�cKs8||_t||�|_|j��|_|j��|j�|�dSr()r�rF�target�copyr��clear�update)rr��attrnamer5rrrr�ns

z_MonkeyDict.__init__cCs|jSr()r�r�rrrr�usz_MonkeyDict.__enter__cCs|j��|j�|j�dSr()r�r�r�r�)rr�r�r�rrrr�xs
z_MonkeyDict.__exit__Nr�rrrrr�lsr�)'�__doc__Zunittestr
rr%rZTestCaserr/rtr�r�r�r�r�r�r�r�r�rrrr2r6r<rHrKrOrUrZr\rhrurxr�r�r�rr�rrrr�<module>sN'V'>C>6<2A 1-".@;FM4
�