HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/unittest/test/testmock/__pycache__/testsealable.cpython-310.opt-2.pyc
o

�i��@sLddlZddlmZGdd�d�ZGdd�dej�Zedkr$e��dSdS)�N)�mockc@seZdZdd�Zdd�ZdS)�SampleObjectcC�dS�N���selfrr�@/usr/local/lib/python3.10/unittest/test/testmock/testsealable.py�method_sample1�zSampleObject.method_sample1cCrrrrrrr	�method_sample2	rzSampleObject.method_sample2N)�__name__�
__module__�__qualname__r
rrrrr	rs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'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_defaultcCsxt��}t�|�|�t��|jWd�n1swY|�t��|�Wd�dS1s5wYdSr�rr�seal�assertRaises�AttributeErrorrrrrr	�.test_new_attributes_cannot_be_accessed_on_seals
�"�z;TestSealable.test_new_attributes_cannot_be_accessed_on_sealcCsHt��}t�|�|�t��d|_Wd�dS1swYdS�N�rrrrr	�)test_new_attributes_cannot_be_set_on_seal�

"�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_sealcCsRt��}d|j_t�|�|�t��
d|j_Wd�dS1s"wYdSr)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=�
z;TestSealable.test_initialized_attributes_allowed_after_sealcCsHt��}t�|�|�t��|�Wd�dS1swYdSr)rrrrrrrrr	�test_call_on_sealed_mock_failsCr z+TestSealable.test_call_on_sealed_mock_failscCs(tjdd�}t�|�|�|�d�dS)N�)r()rrrr"rrrr	�)test_call_on_defined_sealed_mock_succeedsJr,z6TestSealable.test_call_on_defined_sealed_mock_succeedscCs�t��}d|j��_t�|�|�|j��jd�|�t��|j��j	Wd�n1s/wY|�t��
|jjWd�dS1sIwYdS�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�n1sHwY|�t��|jjdd�j	Wd�dS1sgwYdS)Nr1�ar!r.)
r�	MagicMockr2rr$rr"rrr3rrrr	�#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_sealedr1r)rrr2rr$rr"r3rrrr	�,test_seals_dont_recurse_on_manual_attributesjs


z9TestSealable.test_seals_dont_recurse_on_manual_attributescCst	t�t�}d|_d|_t�|�|�|jd�|�|jd�|�t��|j	Wd�dS1s3wYdS)Nrr')
rrrZattr_sample1Zattr_sample3rr"rrZattr_sample2rrrr	�)test_integration_with_spec_att_definitionus

"�z6TestSealable.test_integration_with_spec_att_definitioncCsf	t�t�}d|j_t�|�|�|��d�|�t��
|�	�Wd�dS1s,wYdSr)
rrrr
r(rr"rrrrrrr	�,test_integration_with_spec_method_definition�s


"�z9TestSealable.test_integration_with_spec_method_definitioncCsD	t�t�}|�t��
d|j_Wd�dS1swYdSr&)rrrrrZmethod_sample3r(rrrr	�:test_integration_with_spec_method_definition_respects_spec�s


"�zGTestSealable.test_integration_with_spec_method_definition_respects_speccCsXt��}t�|�|�t��}|jWd�n1swY|�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�n1s(wY|�
dt|j��dS)NZ	mock_namer8z&mock_name.test1.test2.test3.test4.boom)
rrr2rr$r3rrrZboomr?r@rArBrrr	�"test_attribute_chain_is_maintained�s
�z/TestSealable.test_attribute_chain_is_maintainedcCstt��}|��j��jt�|�|�t��}|��j����Wd�n1s*wY|�	dt
|j��dS)Nz mock.test1().test2.test3().test4)rrr2rr$r3rrrr?r@rArBrrr	�test_call_chain_is_maintained�s
�z*TestSealable.test_call_chain_is_maintainedc
CsHGdd�d�}dD�]�}|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�n1s�wY|�t��d	|_Wd�n1s�wY|�t��|��Wd�n1s�wYd
|j_|�|��d
�|�t��|jWd�n1s�wY|�t��d	|_Wd�n	1�swY|�t��|��Wd�n	1�s"wY|�t��
|j�
�Wd�n	1�s=wY|�t��|jjWd�n	1�sWwY|�t��d	|j_Wd�n	1�sqwY|�t��
|j��Wd�n	1�s�wYWd�n	1�s�wYq	dS)Nc@s.eZdZdZdd�Zdd�ZGdd�d�ZdS)	z1TestSealable.test_seal_with_autospec.<locals>.FoorcS�dSrrrrrr	�bar1��z6TestSealable.test_seal_with_autospec.<locals>.Foo.bar1cSrG)Nr!rrrrr	�bar2�rIz6TestSealable.test_seal_with_autospec.<locals>.Foo.bar2c@seZdZdZdd�ZdS)z5TestSealable.test_seal_with_autospec.<locals>.Foo.Bazr'cSrGr0rrrrr	�ban�rIz9TestSealable.test_seal_with_autospec.<locals>.Foo.Baz.banN)r
rr�bazrKrrrr	�Baz�srMN)r
rr�foorHrJrMrrrr	�Foo�s
rO)TF)�spec_setr5�bZnew_aZnew_brrJ)ZsubTestrZcreate_autospecrHr(rMrKrrrNZNonCallableMagicMockr6rJrLr"r�	TypeErrorrZbarZmissing_attrZmissing_method)rrOrPrNrrr	�test_seal_with_autospec�sn




��
���
��
�
������z$TestSealable.test_seal_with_autospecN)r
rrrrrr#r%r)r+r-r/r4r7r:r;r<r=rDrErFrSrrrr	rs(	
		r�__main__)ZunittestrrZTestCaserr
�mainrrrr	�<module>sa�