U
    Â“«j  ã                   @  s†   d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ ed	ƒZd
Zdddœdd„ZG dd„ dejƒZdS )z*
Tests for the output generated by trial.
é    )ÚannotationsN)ÚStringIO)ÚTypeVar)Útrial)Úrunner)ÚpackagesÚ_TzNo module named 'frotz'Ústr©ÚargsÚreturnc                  G  sV   ddl m} t ¡ }| | ¡ tƒ }tj|j||d d�}t 	|¡}| 
|¡ | ¡ S )Nr   )Úreporterztemp-directory)ÚstreamZworkingDirectory)Útwisted.trialr   r   ÚOptionsZparseOptionsr   r   ZTrialRunnerZVerboseTextReporterZ	_getSuiteÚrunÚgetvalue)r   r   ÚconfigÚoutputZmyRunnerZsuite© r   úB/tmp/pip-unpacked-wheel-59kc99xd/twisted/trial/test/test_output.pyÚrunTrial   s    
ý

r   c                      s>  e Zd ZdZddœdd„ZdZdddœd	d
„Zdddœdd„Zddddddœ‡ fdd„Zddddddœ‡ fdd„Z	ddœdd„Z
ddœdd„Zddœdd„Zddœdd„Zddœdd„Zddœdd „Zddœd!d"„Zddœd#d$„Zddœd%d&„Zddœd'd(„Zddœd)d*„Zddœd+d,„Zddœd-d.„Zddœd/d0„Z‡  ZS )1ÚImportErrorsTestszbActually run trial as if on the command line and check that the output
    is what we expect.
    ÚNone)r   c                 C  s   d S ©Nr   ©Úselfr   r   r   Údebug+   s    zImportErrorsTests.debugZ_testImportErrorsr	   r
   c                 G  s   t d|  ¡ f|žŽ S )Nz--temp-directory)r   Úmktemp)r   r   r   r   r   r   0   s    zImportErrorsTests.runTrialr   )Ústuffr   c                 C  s   t |ƒ |S r   )Úprint)r   r   r   r   r   Ú_print3   s    zImportErrorsTests._printÚobject)Ú	containerÚ	containeer   Úkwargsr   c                   s   t ƒ j||f|ž|Ž |S r   )ÚsuperÚassertIn©r   r#   r$   r   r%   ©Ú	__class__r   r   r'   7   s    zImportErrorsTests.assertInc                   s   t ƒ j||f|ž|Ž |S 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_nonexistentModuleH   s    
z(ImportErrorsTests.test_nonexistentModulec                 C  s2   |   d¡}|  |d¡ |  |d¡ |  |d¡ |S )NZdoesntexistZModuleNotFoundr-   r.   r/   r   r   r   Útest_nonexistentPackageN   s
    
z)ImportErrorsTests.test_nonexistentPackagec                 C  s2   |   d¡}|  |d¡ |  |d¡ |  |d¡ |S )Nzdoesntexist.barneyZObjectNotFoundr-   r.   r/   r   r   r   Ú!test_nonexistentPackageWithModuleU   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-   r4   r5   r/   r   r   r   Útest_moduleInBadpackagec   s
    
z)ImportErrorsTests.test_moduleInBadpackagec                 C  s>   |   d¡}|  |d¡ |  |d¡ |  |d¡ |  |d¡ |S )Nzpackage.test_bad_moduler-   r4   ú<module r5   r/   r   r   r   Útest_badmodulej   s    
z ImportErrorsTests.test_badmodulec                 C  s>   |   d¡}|  |d¡ |  |d¡ |  |d¡ |  |d¡ |S )Nzpackage.test_import_moduler-   r4   r8   r5   r/   r   r   r   Útest_badimportr   s    
z ImportErrorsTests.test_badimportc                 C  sJ   |   d¡}|  |d¡ |  |d¡ |  |d¡ |  |d¡ |  |d¡ |S )NÚpackager-   Ztest_bad_moduleZtest_import_moduler8   r4   r5   r/   r   r   r   Útest_recurseImportz   s    
z$ImportErrorsTests.test_recurseImportc                 C  sV   |   d¡}|  |d¡ |  |d¡ |  |d¡ |  |t¡ |  |d¡ |  |d¡ |S )NÚpackage2r-   Ztest_moduler8   r4   ©r   r'   Ú_noModuleErrorr+   r/   r   r   r   Útest_recurseImportErrorsƒ   s    
z*ImportErrorsTests.test_recurseImportErrorsc                 C  s4   |   dd¡}|  |d¡ |  |t¡ |  |d¡ |S )Nz-Nr=   r-   r8   r>   r/   r   r   r   Útest_nonRecurseImportErrors�   s
    z-ImportErrorsTests.test_nonRecurseImportErrorsc                 C  s>   |   d¡}|  |d¡ |  |d¡ |  |d¡ |  |d¡ |S )Nzpackage.test_moduler-   r4   Ú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-   r4   rB   rC   ©	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-   r4   rB   rC   rE   r/   r   r   r   Útest_dosFile¥   s    zImportErrorsTests.test_dosFile)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   rI   r   r!   r'   r+   r,   r1   r2   r3   r6   r7   r9   r:   r<   r@   rA   rD   rJ   rK   Ú__classcell__r   r   r)   r   r   &   s*   	
	r   )rO   Ú
__future__r   rF   Úior   Útypingr   Ztwisted.scriptsr   r   r   Ztwisted.trial.testr   r   r?   r   ZSysPathManglingTestr   r   r   r   r   Ú<module>   s   