Your IP : 216.73.216.85


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.pyc



��Yf�)�@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__�findZrunZfailuresZtries�test�supportZ
TestFailed�print)�obj�module�finderZrunner�nameZexample�f�t�r�@/opt/alt/python35/lib64/python3.5/test/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���)9r5r6r�replacerr	r
r�splitrrr/rr�zipfileZZipFile�itemsZwritestr�closerrZprintdirr0r3r$r%r4r=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_reportflagsrr7)r)r8Zsample_sources�mod�srcZmod_namer9�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�dedentrrr/rrrr�ascii�assertIn�encoder)r)r8�patternr9rL�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)
                    rOsl
zutf-8r.z__main__.py)rPrQrrr/rr�stdin�writerrSr0r%�normcaserTr)r)r8r9rL�p�datar:r;rrr�test_pdb_issue4201�s	%	z"ZipSupportTests.test_pdb_issue4201N)	rr
rr*r+r<rNrYr_rrrrr8s	]rcCstjj�dS)N)rrZ
reap_childrenrrrr�tearDownModule�sr`�__main__)Ztest.supportrr0Zos.pathr$rPrEr!rr5rZpdbZunittestZtest.support.script_helperrrrrrrrrrr	r
rZTestCaserr`r�mainrrrr�<module>s&("�