Sindbad~EG File Manager

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

a

��g�)�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
mZmZmZmZejjZddlmZmZmZmZdd�ZGdd�dej�Zdd	�Zed
kr�e��dS)�N)�spawn_python�kill_python�assert_python_ok�make_script�make_zip_script)�test_doctest�sample_doctest�sample_doctest_no_doctests�sample_doctest_no_docstringscCs�tjtdd�}tjtd�}zd|j|jf}WntyF|j}Yn0|�|||�D]}|�	|�qV|j
|j}}|r�tj
�d||f��tr�td|j|f�||fS)NF)�verboseZrecurse)rz%s.%sz%d of %d doctests failedz,doctest (%s) ... %d tests with zero failures)�doctestZ
DocTestFinderrZ
DocTestRunner�
__module__�__qualname__�AttributeError�__name__�find�runZfailuresZtries�test�supportZ
TestFailed�print)�obj�module�finderZrunner�nameZexample�f�t�r�7/usr/local/lib/python3.9/test/test_zipimport_support.py�_run_object_doctest#src@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ZipSupportTestscCsPt��tj��tjdd�|_tjdd�|_tjdd�|_tj	��dS�N)
�	linecache�
clearcache�	zipimport�_zip_directory_cache�clear�sys�path�	meta_path�
path_hooks�path_importer_cache��selfrrr�setUp@s
zZipSupportTests.setUpcCs>|jtjdd�<|jtjdd�<|jtjdd�<tj��dSr )r'r&r(r)r*r%r+rrr�tearDownHszZipSupportTests.tearDownc	Cs�d}tj����}t|d|�}tj�dtj�|��}t|d||�\}}t�	|�t
j�d|�ddl}z |�
t�|j�|�Wt
jd=n
t
jd=0Wd�n1s�0YdS)Nzdef foo(): pass
�__init__�zip_pkg�test_zipr)rr�temp_dirr�osr'�join�basenamer�remover&�insertr0ZassertEqual�inspect�	getsourceZfoo�modules)r,�test_src�dZ	init_nameZname_in_zip�zip_name�run_namer0rrr� test_inspect_getsource_issue4223Ns
��
z0ZipSupportTests.test_inspect_getsource_issue4223cCsPt�t�}|�dd�}|�dd�}|�dd�}i}tttfD]>}t�|�}|�dd�}|j�d�d}|�d	d
�}|||<q<t	j
�����}t|d|�}t
|d|�\}}	t�|d��2}
|��D]\}}|
�|d
|�q�Wd�n1s�0Yt�r<t�|d��$}td|�|��Wd�n1�s20Yt�|�tj�d|�ddl}z�|j|jj|jjj|jj|jj|jj|jj |jj!|jj"|j#|j#j|j#j!|j#j"|j$|j%|j&|j'j(|j'j)|j'j*|j'j+|j'j,|j-|j.|j/|j0|j1|j2g}
|j3|j4|j5g}|
D]}t6||��qWtj7d=n
tj7d=0Wd�n1�sB0YdS)Nzfrom test import test_doctestz*import test_zipped_doctest as test_doctestztest.test_doctest�test_zipped_doctestztest.sample_doctestZsample_zipped_doctest�.���Zsample_Zsample_zipped_r1�az.py�rzContents of %r:r)8r8r9r�replacerr	r
r�splitrrr2rr�zipfile�ZipFile�itemsZwritestrrrZprintdirr3r6r&r'r7r@ZSampleClassZNestedClassr/Z
a_classmethodZ
a_propertyZa_staticmethodZdouble�getZSampleNewStyleClassZsample_funcZtest_DocTestZtest_DocTestParserZtest_DocTestRunnerZbasics�
exceptionsZoption_directivesZoptionflagsZverbose_flagZtest_ExampleZ
test_debugZtest_testsourceZtest_trailing_space_in_testZtest_DocTestSuiteZtest_DocTestFinderZtest_DocFileSuiteZ
test_testfileZtest_unittest_reportflagsrr:)r,r;Zsample_sources�mod�srcZmod_namer<�script_namer=r>�zZzip_filer@Zknown_good_testsZfail_due_to_missing_data_filesrrrr�test_doctest_issue4197^s�
����

��0(
	� �z&ZipSupportTests.test_doctest_issue4197cCs�t�d�}d}tj����}t|d|�}t|�\}}}||df}trbtd|�td�tt	|��|�
|�d�|�t|d|d	�\}	}
t|	�\}}}||
df}tr�td|�td�tt	|��|�
|�d�|�Wd�n1s�0YdS)
Nz�                    class Test:
                        ">>> 'line 2'"
                        pass

                    import doctest
                    doctest.testmod()
                    zFile "%s", line 2, in %s�scriptz
__main__.Testz
Expected linezGot stdout:�utf-8r1�__main__.py)
�textwrap�dedentrrr2rrrr�ascii�assertIn�encoder)r,r;�patternr<rN�rc�out�errZexpectedr=r>rrr�test_doctest_main_issue4197�s*

�
z+ZipSupportTests.test_doctest_main_issue4197cCs�t�d�}tj����}t|d|�}t|�}|j�d�t	|�}|�
tj�
|�d��|�t|d|d�\}}t|�}|j�d�t	|�}|�
tj�
|�d��|�Wd�n1s�0YdS)Nz�                    def f():
                        pass

                    import pdb
                    pdb.Pdb(nosigint=True).runcall(f)
                    rQsl
rRr1rS)rTrUrrr2rr�stdin�writerrWr3r'�normcaserXr)r,r;r<rN�p�datar=r>rrr�test_pdb_issue4201�s
�z"ZipSupportTests.test_pdb_issue4201N)	rr
rr-r.r?rPr]rcrrrrr7s	[rcCstj��dSr )rr�
reap_childrenrrrr�tearDownModule�sre�__main__)Ztest.supportrr3Zos.pathr&rTrGr#rr8r!ZunittestZtest.support.script_helperrrrrrrrrrr	r
rZTestCaserrer�mainrrrr�<module>s&8

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