Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/unittest/test/testmock/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/unittest/test/testmock/__pycache__/testsealable.cpython-38.opt-1.pyc
U

@��g��@sHddlZddlmZGdd�d�ZGdd�dej�ZedkrDe��dS)�N)�mockc@seZdZdd�Zdd�ZdS)�SampleObjectcCsdS�N���selfrr�B/opt/cppython/lib/python3.8/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%S)&�TestSealablecCsDt��}|�|jtj�|�|��tj�|�|����tj�dSr)r�MockZassertIsInstance�test�test2�r�mrrr�,test_attributes_return_more_mocks_by_defaultsz9TestSealable.test_attributes_return_more_mocks_by_defaultc	CsNt��}t�|�|�t��|jW5QRX|�t��|�W5QRXdSr�rr�seal�assertRaises�AttributeErrorrrrrr�.test_new_attributes_cannot_be_accessed_on_seals
z;TestSealable.test_new_attributes_cannot_be_accessed_on_sealc	Cs2t��}t�|�|�t��d|_W5QRXdS�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_sealc	Cs<t��}d|j_t�|�|�t��d|j_W5QRXdSr)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_valuerrrrrr�+test_existing_attributes_allowed_after_seal5s
z8TestSealable.test_existing_attributes_allowed_after_sealcCs(tjdd�}t�|�|�|jd�dS)Nr)�
test_value)rrrrr&rrrr�.test_initialized_attributes_allowed_after_seal=s
z;TestSealable.test_initialized_attributes_allowed_after_sealc	Cs2t��}t�|�|�t��|�W5QRXdSr)rrrrrrrrr�test_call_on_sealed_mock_failsCs
z+TestSealable.test_call_on_sealed_mock_failscCs(tjdd�}t�|�|�|�d�dS)N�)r$)rrrrrrrr�)test_call_on_defined_sealed_mock_succeedsJs
z6TestSealable.test_call_on_defined_sealed_mock_succeedsc	Csvt��}d|j��_t�|�|�|j��jd�|�t��|j��j	W5QRX|�t��|jjW5QRXdS)N�)
rr�test1rr!rrrr�test4rrrr�&test_seals_recurse_on_added_attributesPs
z3TestSealable.test_seals_recurse_on_added_attributesc	Cs�t��}d|jjd_d|jjdd�_t�|�|�|jjdjd�|�|jjdd�jd�|�t��|jjdj	W5QRX|�t��|jjdd�j	W5QRXdS)Nr+�arr))
rZ	MagicMockr,rr!rrrrr-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!rrr-rrrr�,test_seals_dont_recurse_on_manual_attributesjs


z9TestSealable.test_seals_dont_recurse_on_manual_attributesc	Cs\t�t�}d|_d|_t�|�|�|jd�|�|jd�|�t��|j	W5QRXdS)z0You are not restricted when using mock with specrr#N)
rrrZattr_sample1Zattr_sample3rrrrZattr_sample2rrrr�)test_integration_with_spec_att_definitionus

z6TestSealable.test_integration_with_spec_att_definitionc	CsNt�t�}d|j_t�|�|�|��d�|�t��|�	�W5QRXdS)z;You need to defin the methods, even if they are in the specrN)
rrrr	r$rrrrrrrrr�,test_integration_with_spec_method_definition�s

z9TestSealable.test_integration_with_spec_method_definitionc	Cs,t�t�}|�t��d|j_W5QRXdS)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_specc	CsDt��}t�|�|�t��}|jW5QRX|�dt|j��dS)N�SECRETE_name)	rrrrrr7�assertIn�str�	exception�rr�cmrrr�(test_sealed_exception_has_attribute_name�s

z5TestSealable.test_sealed_exception_has_attribute_namec	Cs\tjdd�}|jjjjt�|�|�t��}|jjjjj	W5QRX|�
dt|j��dS)NZ	mock_namer1z&mock_name.test1.test2.test3.test4.boom)
rrr,rr!r-rrrZboomr8r9r:r;rrr�"test_attribute_chain_is_maintained�s
z/TestSealable.test_attribute_chain_is_maintainedc	Cs`t��}|��j��jt�|�|�t��}|��j����W5QRX|�	dt
|j��dS)Nz mock.test1().test2.test3().test4)rrr,rr!r-rrrr8r9r:r;rrr�test_call_chain_is_maintained�s
z*TestSealable.test_call_chain_is_maintainedN)rr
rrrrr r"r%r'r(r*r.r0r3r4r5r6r=r>r?rrrrrs$	
	r�__main__)ZunittestrrZTestCaserr�mainrrrr�<module>s$

F1le Man4ger