[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.23.128.244: ~ $


2*�V[)�@s�ddlmZddlZddlmZddlmZmZm	Z	m
Z
mZmZe
j
Ze
jZGdd�dej�ZGdd�dej�Zed	kr�ej�dS)
�)�catch_warningsN)�is_instance)�	MagicMock�Mock�patch�sentinel�	mock_open�callc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�WithTestcCsKtdttj��|jttjd�WdQRX|jttj�dS)Nz%s.something�	unpatched)r�__name__r�
Something2�assertEqual�	something�	Something)�self�r�/testwith.py�test_with_statementszWithTest.test_with_statementcCs}yDtdttj��'|jttjd�td��WdQRXWntk
rXYnX|jd�|jttj�dS)Nz%s.somethingr�powzpatch swallowed exception)	rrrr
rr�	ExceptionZfailr)rrrr�test_with_statement_exceptions

z&WithTest.test_with_statement_exceptioncCs]tdt��3}|jt|d�|jt|t�d�WdQRX|jttj�dS)Nz%s.somethingrzpatching wrong type)	rrrr�
assertTruerrrr)r�mock_somethingrrr�test_with_statement_as&s
zWithTest.test_with_statement_ascCsfGdd�dt�}|j}tj|d��|j|j|d�WdQRX|j|j|�dS)Nc@seZdZdZdS)z6WithTest.test_patch_object_with_statement.<locals>.Foo�fooN)r�
__module__�__qualname__rrrrr�Foo/srrr)�objectrrZassertNotEqualr)rrZoriginalrrr� test_patch_object_with_statement.s
	z)WithTest.test_patch_object_with_statementcCs�tdd��_tdt��G}tdt��-}|jt|d�|jt|d�WdQRXWdQRXWdQRX|jttj�|jttj�dS)N�recordTz%s.somethingz%s.something_elser)	rrrrr�something_elserr�
SomethingElse)rr�mock_something_elserrr�test_with_statement_nested7sz#WithTest.test_with_statement_nestedcCs`tdttj��0}|jt|d�|j|tjd�WdQRX|jttj�dS)Nz%s.somethingrzwrong patch)rrr�Patchedrrr)rrrrr�test_with_statement_specifiedCsz&WithTest.test_with_statement_specifiedcCszt�}t�|_t�|_d|j_|�}|j||jj�WdQRX|jj�|jjddd�dS)NF)r�	__enter__�__exit__�return_valuer�assert_called_with)r�mock�mrrr�testContextManagerMockingJs		
z"WithTest.testContextManagerMockingcCsZt�}|jt��|�
ddWdQRXWdQRX|jj�|j|jj�dS)Nr�)r�assertRaises�	TypeErrorr(r+rr)Zcalled)rr,rrr�$test_context_manager_with_magic_mockVs	
z-WithTest.test_context_manager_with_magic_mockcCs�tdttj��Z}|jt|d�tdt��}|jt|d�WdQRX|jt|d�WdQRX|jttjd�dS)Nz%s.somethingrzrestored with wrong instanceznot restored)rrrr&rrr)rrZ
mock_againrrr�"test_with_statement_same_attribute`sz+WithTest.test_with_statement_same_attributecCs�tdt��G}|jt|d�tdt��}|jt|d�WdQRXWdQRX|jttj�|jttj�dS)Nz%s.somethingrz%s.something_else)rrrrr"rrr#)rrr$rrr�test_with_statement_imbricatedmsz'WithTest.test_with_statement_imbricatedcCs�i}tj|ddi��|j|ddi�WdQRX|j|i�|jt��Gtj|ddi��'|j|ddi�td��WdQRXWdQRX|j|i�dS)N�a�bZKonrad)r�dictrr0�	NameError)rrrrr�test_dict_context_managerysz"WithTest.test_dict_context_managerN)rrrrrrr r%r'r.r2r3r4r9rrrrr
s	

r
c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�TestMockOpenc
CsWt�}tdt|dd��!}|j||�td�WdQRX|jd�dS)Nz%s.open�createTr)rrr�assertIs�open�assert_called_once_with)rr,�patchedrrr�test_mock_open�s
	zTestMockOpen.test_mock_opencCs�t�}|j}tdt|dd��%td��}|j�WdQRXWdQRXtd�t�j�t�j�t�jddd�g}|j	|j
|�|j||�dS)Nz%s.openr;Tr)rr*rrr=�readr	r(r)r�
mock_callsr<)rr,�handle�f�expected_callsrrr�test_mock_open_context_manager�s		!z+TestMockOpen.test_mock_open_context_managerc Cs�t�}tdt|dd��Etd��}|j�WdQRXtd��}|j�WdQRXWdQRXtd�t�j�t�j�t�jddd�td�t�j�t�j�t�jddd�g}|j|j	|�dS)Nz%s.openr;Tr�bar)
rrrr=rAr	r(r)rrB)rr,rDrErrr�-test_mock_open_context_manager_multiple_times�s	!!z:TestMockOpen.test_mock_open_context_manager_multiple_timesc
Csat�}t|�tdt|dd��!}|j||�td�WdQRX|jd�dS)Nz%s.openr;Tr)rrrrr<r=r>)rr,r?rrr�test_explicit_mock�s	
zTestMockOpen.test_explicit_mockc
Cs\tdd�}tdt|dd��td�}|j�}WdQRX|j|d�dS)N�	read_datarz%s.openr;TrG)rrrr=rAr)rr,�h�resultrrr�test_read_data�s
zTestMockOpen.test_read_datacCs�tdd�}tdt|dd��5td�}|j�}|j�}|j�}WdQRX|j|d�|j|d�|j|d	�tdd
�}tdt|dd��td�}|j�}WdQRX|j|d
�dS)NrJzfoo
bar
baz
z%s.openr;TrGzfoo
zbar
zbaz
r)rrrr=�readliner)rr,rK�line1�line2�line3rLrrr�test_readline_data�szTestMockOpen.test_readline_datacCs�tdd�}tdt|dd��td�}|j�}WdQRX|j|ddd	g�tdd
�}tdt|dd��td�}|j�}WdQRX|j|dddg�dS)NrJzfoo
bar
baz
z%s.openr;TrGzfoo
zbar
zbaz
zfoo
bar
bazZbaz)rrrr=�	readlinesr)rr,rKrLrrr�test_readlines_data�sz TestMockOpen.test_readlines_datacCsitdd�}tdt|dd��*tdd��}|j�}WdQRXWdQRX|j|d�dS)NrJs�z%s.openr;T�abc�rb)rrrr=rAr)rr,rDrLrrr�test_read_bytes�s
zTestMockOpen.test_read_bytescCs�tdd�}tdt|dd��Btdd��+}|j�}|j�}|j�}WdQRXWdQRX|j|d�|j|d	�|j|d
�dS)NrJsabc
def
ghi
z%s.openr;TrUrVsabc
sdef
sghi
)rrrr=rNr)rr-rDrOrPrQrrr�test_readline_bytes�sz TestMockOpen.test_readline_bytescCsrtdd�}tdt|dd��*tdd��}|j�}WdQRXWdQRX|j|dd	d
g�dS)NrJsabc
def
ghi
z%s.openr;TrUrVsabc
sdef
sghi
)rrrr=rSr)rr-rDrLrrr�test_readlines_bytes�s
z!TestMockOpen.test_readlines_bytescCs5d}td|�}|j|�jd�|�dS)Nzfoo
bar
bazrJ�
)rrrA)rZ	some_datar,rrr�!test_mock_open_read_with_argumentsz.TestMockOpen.test_mock_open_read_with_argumentcCs�tdd�}tdt|dd��)td�}|j�}|j�}WdQRX|j|d�|j|dd	g�tdd�}tdt|dd��)td�}|j�}|j�}WdQRX|j|d�|j|d
�dS)NrJzfoo
bar
baz
z%s.openr;TrGzfoo
zbar
zbaz
zbar
baz
)rrrr=rNrSrrA)rr,rKrO�restrrr�test_interleaved_readssz#TestMockOpen.test_interleaved_readscCs�tdd�}|�}d|j_d|j_dg|j_|j|j�d�|j|j�d�|j|j�dg�|j|j�d�|j|j�d�dS)NrJrrG)rrAr*rNrSr)rr,rCrrr�test_overriding_return_values s	z*TestMockOpen.test_overriding_return_valuesN)rrrr@rFrHrIrMrRrTrWrXrYr[r]r^rrrrr:�s		r:�__main__)�warningsrZ	unittest2ZunittestZmock.tests.supportrr,rrrrrr	rrr#r"ZTestCaser
r:r�mainrrrr�<module>s.		v�

Filemanager

Name Type Size Permission Actions
__init__.cpython-35.opt-1.pyc File 95 B 0644
__init__.cpython-35.pyc File 95 B 0644
__main__.cpython-35.opt-1.pyc File 569 B 0644
__main__.cpython-35.pyc File 569 B 0644
support.cpython-35.opt-1.pyc File 1.17 KB 0644
support.cpython-35.pyc File 1.17 KB 0644
testcallable.cpython-35.opt-1.pyc File 5.98 KB 0644
testcallable.cpython-35.pyc File 5.98 KB 0644
testhelpers.cpython-35.opt-1.pyc File 36.11 KB 0644
testhelpers.cpython-35.pyc File 36.11 KB 0644
testmagicmethods.cpython-35.opt-1.pyc File 22.61 KB 0644
testmagicmethods.cpython-35.pyc File 22.61 KB 0644
testmock.cpython-35.opt-1.pyc File 49.25 KB 0644
testmock.cpython-35.pyc File 49.25 KB 0644
testpatch.cpython-35.opt-1.pyc File 71.85 KB 0644
testpatch.cpython-35.pyc File 71.85 KB 0644
testsentinel.cpython-35.opt-1.pyc File 1.38 KB 0644
testsentinel.cpython-35.pyc File 1.38 KB 0644
testwith.cpython-35.opt-1.pyc File 10.14 KB 0644
testwith.cpython-35.pyc File 10.14 KB 0644