Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/test/__pycache__/test_zipimport_support.cpython-34.pyo

�
g f�)�@s7ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZmZmZmZmZmZejjZddlmZmZmZmZdd�ZGdd�dej�Zdd	�Zed
kr3e�ndS)�N)�spawn_python�kill_python�assert_python_ok�temp_dir�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�tjj
d||f��ntr�td|j|f�n||fS)N�verboseZrecurseFz%s.%sz%d of %d doctests failedz,doctest (%s) ... %d tests with zero failures)�doctestZ
DocTestFinderrZ
DocTestRunner�
__module__�__name__�AttributeError�findZrunZfailuresZtries�test�supportZ
TestFailed�print)�obj�module�finderZrunner�nameZexample�f�t�r�@/opt/alt/python34/lib64/python3.4/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}t���}t|d|�}tjjdtjj|��}t|d||�\}}tj|�tjj	d|�ddl
}z |jtj
|j�|�Wdtjd=XWdQXdS)Nzdef foo(): pass
�__init__�zip_pkg�test_zipr)rr�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	��
}t
|d|�}t|d|�\}}	tj
|d�}
x.|j�D] \}}|
j|d
|�q
W|
j�trxtj
|d�}td|�|j�|j�ntj|�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-|j.|j/|j0|j1g}
|j2|j3|j4g}x|
D]}t5||�q�WWdtj6d=XWdQXdS)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���)7r4r5r�replacer	r
rr�splitrrr�zipfileZZipFile�itemsZwritestr�closerrZprintdirr/r2r$r%r3r<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_reportflagsrr6)r)r7Zsample_sources�mod�srcZmod_namer8�script_namer9r:�zZzip_filer<Zknown_good_testsZfail_due_to_missing_data_filesrrrr�test_doctest_issue4197_s�						
			



																
z&ZipSupportTests.test_doctest_issue4197cCs4tjd�}d}t��}t|d|�}t|�\}}}||df}tr�td|�td�tt|��n|j|j	d�|�t
|d|d	�\}	}
t|	�\}}}||
df}trtd|�td�tt|��n|j|j	d�|�WdQXdS)
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�dedentrrrrr�ascii�assertIn�encoder)r)r7�patternr8rK�rc�out�errZexpectedr9r:rrr�test_doctest_main_issue4197�s*	

	

z+ZipSupportTests.test_doctest_main_issue4197cCs�tjd�}t���}t|d|�}t|�}|jjd�t|�}|jt	j
j|jd��|�t
|d|d�\}}t|�}|jjd�t|�}|jt	j
j|jd��|�WdQXdS)Nz�                    def f():
                        pass

                    import pdb
                    pdb.Pdb(nosigint=True).runcall(f)
                    rNsl
zutf-8r.z__main__.py)rOrPrrr�stdin�writerrRr/r%�normcaserSr)r)r7r8rK�p�datar9r:rrr�test_pdb_issue4201�s	%	z"ZipSupportTests.test_pdb_issue4201N)	rr�__qualname__r*r+r;rMrXr^rrrrr8s	]rcCs!tjjt�tjj�dS)N)rrZrun_unittestrZ
reap_childrenrrrr�	test_main�sr`�__main__)Ztest.supportrr/Zos.pathr$rOrDr!r
r4rZpdbZunittestZtest.script_helperrrrrrrrrrr	r
rrZTestCaserr`rrrrr�<module>s&."�