Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_zipimport_support.cpython-35.opt-2.pyc



���]�)�@s1ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZmZmZmZmZejjZddlmZmZmZmZdd�ZGdd�dej�Zdd	�Zed
kr-ej�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_docstringscCs�tjdtdd�}tjdt�}yd|j|jf}Wntk
ra|j}YnXx*|j|||�D]}|j	|�qxW|j
|j}}|r�tj
jd||f��tr�td|j|f�||fS)N�verboseZrecurseFz%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�;/opt/alt/python35/lib64/python3.5/test_zipimport_support.py�_run_object_doctest$s
rc@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ZipSupportTestscCsjtj�tjj�tjdd�|_tjdd�|_tjdd�|_tj	j�dS)N)
�	linecache�
clearcache�	zipimport�_zip_directory_cache�clear�sys�path�	meta_path�
path_hooks�path_importer_cache)�selfrrr�setUpAs

zZipSupportTests.setUpcCsS|jtjdd�<|jtjdd�<|jtjdd�<tjj�dS)N)r&r%r'r(r)r$)r*rrr�tearDownIszZipSupportTests.tearDowncCs�d}tjj���}t|d|�}tjjdtjj|��}t|d||�\}}tj	|�t
jjd|�ddl}z |j
tj|j�|�Wdt
jd=XWdQRXdS)Nzdef foo(): pass
�__init__�zip_pkg�test_zipr)rr�temp_dirr�osr&�join�basenamer�remover%�insertr.ZassertEqual�inspect�	getsourceZfoo�modules)r*�test_src�dZ	init_nameZname_in_zip�zip_name�run_namer.rrr� test_inspect_getsource_issue4223Os	
 z0ZipSupportTests.test_inspect_getsource_issue4223c(Cs�tjt�}|jdd�}|jdd�}|jdd�}i}xjtttgD]Y}tj|�}|jdd�}|jjd�d}|jd	d
�}|||<q[Wt	j
j��}t|d|�}t
|d|�\}}	tj|d�}
x.|j�D] \}}|
j|d
|�qW|
j�tr{tj|d�}td|�|j�|j�tj|�tjjd|�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/|j0|j1|j2|j3g}
|j4|j5|j6g}x|
D]}t7||�q�WWdtj8d=XWdQRXdS)Nzfrom test import test_doctestz*import test_zipped_doctest as test_doctestztest.test_doctest�test_zipped_doctestztest.sample_doctestZsample_zipped_doctest�.�Zsample_Zsample_zipped_r/�az.py�rzContents of %r:r���)9r6r7r�replacerr	r
r�splitrrr0rr�zipfile�ZipFile�itemsZwritestr�closerrZprintdirr1r4r%r&r5r>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_reportflagsrr8)r*r9Zsample_sources�mod�srcZmod_namer:�script_namer;r<�zZzip_filer>Zknown_good_testsZfail_due_to_missing_data_filesrrrr�test_doctest_issue4197_s�						
			



																
z&ZipSupportTests.test_doctest_issue4197cCs5tjd�}d}tjj��
}t|d|�}t|�\}}}||df}tr�td|�td�tt	|��|j
|jd�|�t|d|d	�\}	}
t|	�\}}}||
df}trtd|�td�tt	|��|j
|jd�|�WdQRXdS)
Nz�                    class Test:
                        ">>> 'line 2'"
                        pass

                    import doctest
                    doctest.testmod()
                    zFile "%s", line 2, in %s�scriptz
__main__.Testz
Expected linezGot stdout:zutf-8r/z__main__.py)
�textwrap�dedentrrr0rrrr�ascii�assertIn�encoder)r*r9�patternr:rN�rc�out�errZexpectedr;r<rrr�test_doctest_main_issue4197�s*	

	

z+ZipSupportTests.test_doctest_main_issue4197cCs�tjd�}tjj���}t|d|�}t|�}|jjd�t	|�}|j
tjj
|jd��|�t|d|d�\}}t|�}|jjd�t	|�}|j
tjj
|jd��|�WdQRXdS)Nz�                    def f():
                        pass

                    import pdb
                    pdb.Pdb(nosigint=True).runcall(f)
                    rQsl
zutf-8r/z__main__.py)rRrSrrr0rr�stdin�writerrUr1r&�normcaserVr)r*r9r:rN�p�datar;r<rrr�test_pdb_issue4201�s	%	z"ZipSupportTests.test_pdb_issue4201N)	rr
rr+r,r=rPr[rarrrrr8s	]rcCstjj�dS)N)rrZ
reap_childrenrrrr�tearDownModule�srb�__main__)Ztest.supportrr1Zos.pathr%rRrFr"rr6r ZpdbZunittestZtest.support.script_helperrrrrrrrrrr	r
rZTestCaserrbr�mainrrrr�<module>s&("�