Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/unittest/test/testmock/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/unittest/test/testmock/__pycache__/testsealable.cpython-39.pyc

a

��g��@sHddlZddlmZGdd�d�ZGdd�dej�ZedkrDe��dS)�N)�mockc@seZdZdd�Zdd�ZdS)�SampleObjectcCsdS�N���selfrr�?/usr/local/lib/python3.9/unittest/test/testmock/testsealable.py�method_sample1�zSampleObject.method_sample1cCsdSrrrrrr�method_sample2	r
zSampleObject.method_sample2N)�__name__�
__module__�__qualname__r	rrrrrrsrc@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'S)(�TestSealablecCsDt��}|�|jtj�|�|��tj�|�|����tj�dSr)r�Mock�assertIsInstance�test�test2�r�mrrr�,test_attributes_return_more_mocks_by_defaultsz9TestSealable.test_attributes_return_more_mocks_by_defaultcCsvt��}t�|�|�t��|jWd�n1s80Y|�t��|�Wd�n1sh0YdSr�rr�seal�assertRaises�AttributeErrorrrrrr�.test_new_attributes_cannot_be_accessed_on_seals
$z;TestSealable.test_new_attributes_cannot_be_accessed_on_sealcCsFt��}t�|�|�t��d|_Wd�n1s80YdS�N�rrrrr�)test_new_attributes_cannot_be_set_on_seals
z6TestSealable.test_new_attributes_cannot_be_set_on_sealcCs6t��}d|j_t�|�d|j_|�|jjd�dS)Nr�)rrrrr�assertEqualrrrr�+test_existing_attributes_can_be_set_on_seal%s

z8TestSealable.test_existing_attributes_can_be_set_on_sealcCsPt��}d|j_t�|�|�t��d|j_Wd�n1sB0YdSr)rrrrrrr�test3rrrr�2test_new_attributes_cannot_be_set_on_child_of_seal-s

z?TestSealable.test_new_attributes_cannot_be_set_on_child_of_sealcCs.t��}d|j_t�|�|�|��d�dS)N�)rrr�return_valuerr rrrr�+test_existing_attributes_allowed_after_seal5s
z8TestSealable.test_existing_attributes_allowed_after_sealcCs(tjdd�}t�|�|�|jd�dS)Nr)�
test_value)rrrr r'rrrr�.test_initialized_attributes_allowed_after_seal=s
z;TestSealable.test_initialized_attributes_allowed_after_sealcCsFt��}t�|�|�t��|�Wd�n1s80YdSr)rrrrrrrrr�test_call_on_sealed_mock_failsCs
z+TestSealable.test_call_on_sealed_mock_failscCs(tjdd�}t�|�|�|�d�dS)N�)r%)rrrr rrrr�)test_call_on_defined_sealed_mock_succeedsJs
z6TestSealable.test_call_on_defined_sealed_mock_succeedscCs�t��}d|j��_t�|�|�|j��jd�|�t��|j��j	Wd�n1s^0Y|�t��|jjWd�n1s�0YdS�N�)
rr�test1rr"rr rr�test4rrrr�&test_seals_recurse_on_added_attributesPs
*z3TestSealable.test_seals_recurse_on_added_attributescCs�t��}d|jjd_d|jjdd�_t�|�|�|jjdjd�|�|jjdd�jd�|�t��|jjdj	Wd�n1s�0Y|�t��"|jjdd�j	Wd�n1s�0YdS)Nr-�arr*)
r�	MagicMockr.rr"rr rrr/rrrr�#test_seals_recurse_on_magic_methods\s
,z0TestSealable.test_seals_recurse_on_magic_methodscCsZtjdd�}tjdd�|j_d|jj_t�|�|�|jjjd�|jjjd|jj_dS)NZ	root_mock��nameZ
not_sealedr-r)rrr.rr"rr r/rrrr�,test_seals_dont_recurse_on_manual_attributesjs


z9TestSealable.test_seals_dont_recurse_on_manual_attributescCspt�t�}d|_d|_t�|�|�|jd�|�|jd�|�t��|j	Wd�n1sb0YdS)z0You are not restricted when using mock with specrr$N)
rrrZattr_sample1Zattr_sample3rr rrZattr_sample2rrrr�)test_integration_with_spec_att_definitionus

z6TestSealable.test_integration_with_spec_att_definitioncCsbt�t�}d|j_t�|�|�|��d�|�t��|�	�Wd�n1sT0YdS)z<You need to define the methods, even if they are in the specrN)
rrrr	r%rr rrrrrrr�,test_integration_with_spec_method_definition�s

z9TestSealable.test_integration_with_spec_method_definitioncCs@t�t�}|�t��d|j_Wd�n1s20YdS)z)You cannot define methods out of the specr$N)rrrrrZmethod_sample3r%rrrr�:test_integration_with_spec_method_definition_respects_spec�s
zGTestSealable.test_integration_with_spec_method_definition_respects_speccCsXt��}t�|�|�t��}|jWd�n1s80Y|�dt|j��dS)N�SECRETE_name)	rrrrrr:�assertIn�str�	exception�rr�cmrrr�(test_sealed_exception_has_attribute_name�s

$z5TestSealable.test_sealed_exception_has_attribute_namecCsptjdd�}|jjjjt�|�|�t��}|jjjjj	Wd�n1sP0Y|�
dt|j��dS)NZ	mock_namer4z&mock_name.test1.test2.test3.test4.boom)
rrr.rr"r/rrrZboomr;r<r=r>rrr�"test_attribute_chain_is_maintained�s
,z/TestSealable.test_attribute_chain_is_maintainedcCstt��}|��j��jt�|�|�t��"}|��j����Wd�n1sT0Y|�	dt
|j��dS)Nz mock.test1().test2.test3().test4)rrr.rr"r/rrrr;r<r=r>rrr�test_call_chain_is_maintained�s
0z*TestSealable.test_call_chain_is_maintainedc
CsPGdd�d�}dD�]6}|j|d���tj||d�}d|j_d|jj_t�|�|�|j	tj
�|�|jtj�|�|jtj�|�|jtj�|�|jj
tj
�|�|jjtj�|�|��d�d|j_|�|��d�|�|j��d�d|jj_|�|j��d�|�t��|�	�Wd�n1�s60Y|�t��d	|_Wd�n1�sh0Y|�t��|��Wd�n1�s�0Yd
|j_|�|��d
�|�t��|jWd�n1�s�0Y|�t��d	|_Wd�n1�s0Y|�t��|��Wd�n1�sL0Y|�t��|j�
�Wd�n1�s�0Y|�t��|jjWd�n1�s�0Y|�t��d	|j_Wd�n1�s�0Y|�t��|j��Wd�n1�s 0YWd�q1�s@0YqdS)Nc@s.eZdZdZdd�Zdd�ZGdd�d�ZdS)	z1TestSealable.test_seal_with_autospec.<locals>.FoorcSsdSrrrrrr�bar1�sz6TestSealable.test_seal_with_autospec.<locals>.Foo.bar1cSsdS)Nrrrrrr�bar2�sz6TestSealable.test_seal_with_autospec.<locals>.Foo.bar2c@seZdZdZdd�ZdS)z5TestSealable.test_seal_with_autospec.<locals>.Foo.Bazr$cSsdSr,rrrrr�ban�sz9TestSealable.test_seal_with_autospec.<locals>.Foo.Baz.banN)rr
r�bazrErrrr�Baz�srGN)rr
r�foorCrDrGrrrr�Foo�srI)TF)�spec_setr1�bZnew_aZnew_brrD)ZsubTestrZcreate_autospecrCr%rGrErrrHZNonCallableMagicMockr2rDrFr r�	TypeErrorrZbarZmissing_attrZmissing_method)rrIrJrHrrr�test_seal_with_autospec�sR



(&(&&(*((z$TestSealable.test_seal_with_autospecN)rr
rrrrr!r#r&r(r)r+r0r3r6r7r8r9r@rArBrMrrrrrs&	
		r�__main__)ZunittestrrZTestCaserr�mainrrrr�<module>sa

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists