U
    
W[³  ã                   @   s€   d Z ddlmZmZmZ ddlZddlmZmZ ddl	m
Z
 ddlmZ ddlmZ er^dZnd	Zd
d„ ZG dd„ dejƒZdS )z*
Tests for the output generated by trial.
é    )Úabsolute_importÚdivisionÚprint_functionN)ÚNativeStringIOÚ_PY3)Útrial)Úrunner)ÚpackageszNo module named 'frotz'zNo module named frotzc                  G   sV   ddl m} t ¡ }| | ¡ tƒ }tj|j||d d}t 	|¡}| 
|¡ | ¡ S )Nr   )Úreporterztemp-directory)ÚstreamZworkingDirectory)Útwisted.trialr
   r   ZOptionsZparseOptionsr   r   ZTrialRunnerZVerboseTextReporterZ	_getSuiteÚrunÚgetvalue)Úargsr
   ZconfigÚoutputZmyRunnerZsuite© r   ú@/usr/lib/python3/dist-packages/twisted/trial/test/test_output.pyÚrunTrial   s    
ý

r   c                       s´   e Zd ZdZdZdZdd„ Zdd„ Z‡ fdd	„Z‡ fd
d„Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Z‡  ZS )(ÚImportErrorsTestszbActually run trial as if on the command line and check that the output
    is what we expect.
    FZ_testImportErrorsc                 G   s   t d|  ¡ f|žŽ S )Nz--temp-directory)r   Zmktemp)Úselfr   r   r   r   r   .   s    zImportErrorsTests.runTrialc                 C   s   t |ƒ |S ©N)Úprint)r   Zstuffr   r   r   Ú_print2   s    zImportErrorsTests._printc                    s   t t| ƒj||f|ž|Ž |S r   )Úsuperr   ÚassertIn©r   Z	containerZ	containeer   Úkwargs©Ú	__class__r   r   r   7   s    
 ÿÿÿzImportErrorsTests.assertInc                    s   t t| ƒj||f|ž|Ž |S r   )r   r   ÚassertNotInr   r   r   r   r   >   s    
 ÿÿÿzImportErrorsTests.assertNotInc                 C   s   |   ¡  d S r   )r   )r   r   r   r   Útest_trialRunE   s    zImportErrorsTests.test_trialRunc                 C   s&   |   d¡}|  |d¡ |  |d¡ |S )Nztwisted.doesntexistú[ERROR]©r   r   ©r   Údr   r   r   Útest_nonexistentModuleI   s    
z(ImportErrorsTests.test_nonexistentModulec                 C   s2   |   d¡}|  |d¡ |  |d¡ |  |d¡ |S )NZdoesntexistZModuleNotFoundr!   r"   r#   r   r   r   Útest_nonexistentPackageP   s
    
z)ImportErrorsTests.test_nonexistentPackagec                 C   s2   |   d¡}|  |d¡ |  |d¡ |  |d¡ |S )Nzdoesntexist.barneyZObjectNotFoundr!   r"   r#   r   r   r   Ú!test_nonexistentPackageWithModuleX   s
    
z3ImportErrorsTests.test_nonexistentPackageWithModulec                 C   s2   |   d¡}|  |d¡ |  |d¡ |  |d¡ |S )NZ
badpackager!   ÚIOError©r   r   r   r#   r   r   r   Útest_badpackage`   s
    
z!ImportErrorsTests.test_badpackagec                 C   s2   |   d¡}|  |d¡ |  |d¡ |  |d¡ |S )Nzbadpackage.test_moduler!   r(   r)   r#   r   r   r   Útest_moduleInBadpackageh   s
    
z)ImportErrorsTests.test_moduleInBadpackagec                 C   s>   |   d¡}|  |d¡ |  |d¡ |  |d¡ |  |d¡ |S )Nzpackage.test_bad_moduler!   r(   ú<module r)   r#   r   r   r   Útest_badmodulep   s    
z ImportErrorsTests.test_badmodulec                 C   s>   |   d¡}|  |d¡ |  |d¡ |  |d¡ |  |d¡ |S )Nzpackage.test_import_moduler!   r(   r,   r)   r#   r   r   r   Útest_badimporty   s    
z ImportErrorsTests.test_badimportc                 C   sJ   |   d¡}|  |d¡ |  |d¡ |  |d¡ |  |d¡ |  |d¡ |S )NÚpackager!   Ztest_bad_moduleZtest_import_moduler,   r(   r)   r#   r   r   r   Útest_recurseImport‚   s    
z$ImportErrorsTests.test_recurseImportc                 C   sV   |   d¡}|  |d¡ |  |d¡ |  |d¡ |  |t¡ |  |d¡ |  |d¡ |S )NÚpackage2r!   Ztest_moduler,   r(   ©r   r   Ú_noModuleErrorr   r#   r   r   r   Útest_recurseImportErrorsŒ   s    
z*ImportErrorsTests.test_recurseImportErrorsc                 C   s4   |   dd¡}|  |d¡ |  |t¡ |  |d¡ |S )Nz-Nr1   r!   r,   r2   r#   r   r   r   Útest_nonRecurseImportErrors—   s
    z-ImportErrorsTests.test_nonRecurseImportErrorsc                 C   s>   |   d¡}|  |d¡ |  |d¡ |  |d¡ |  |d¡ |S )Nzpackage.test_moduler!   r(   ÚOKúPASSED (successes=1))r   r   r   r#   r   r   r   Útest_regularRunŸ   s    
z!ImportErrorsTests.test_regularRunc                 C   sX   |   | j¡ |  tj | jdd¡¡}|  |d¡ |  |d¡ |  |d¡ |  |d¡ |S )Nr/   ztest_module.pyr!   r(   r6   r7   ©	ZmangleSysPathZoldPathr   ÚosÚpathÚjoinÚparentr   r   r#   r   r   r   Útest_filename¨   s    ÿzImportErrorsTests.test_filenamec                 C   sX   |   | j¡ |  tj | jdd¡¡}|  |d¡ |  |d¡ |  |d¡ |  |d¡ |S )Nr/   ztest_dos_module.pyr!   r(   r6   r7   r9   r#   r   r   r   Útest_dosFile³   s    
 ÿÿzImportErrorsTests.test_dosFile)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Údebugr=   r   r   r   r   r    r%   r&   r'   r*   r+   r-   r.   r0   r4   r5   r8   r>   r?   Ú__classcell__r   r   r   r   r   '   s*   		
	r   )rC   Z
__future__r   r   r   r:   Ztwisted.python.compatr   r   Ztwisted.scriptsr   r   r   Ztwisted.trial.testr	   r3   r   ZSysPathManglingTestr   r   r   r   r   Ú<module>   s   