o
    ¯b˜  ã                   @   s^   d 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Z
dd	„ ZG d
d„ de	jƒZdS )z*
Tests for the output generated by trial.
é    N)ÚStringIO)Útrial)Úrunner)ÚpackageszNo module named 'frotz'c                  G   sV   ddl m} t ¡ }| | ¡ tƒ }tj|j||d d}t 	|¡}| 
|¡ | ¡ S )Nr   )Úreporterztemp-directory)ÚstreamÚworkingDirectory)Útwisted.trialr   r   ÚOptionsÚparseOptionsr   r   ÚTrialRunnerÚVerboseTextReporterÚ	_getSuiteÚrunÚgetvalue)Úargsr   ÚconfigÚoutputÚmyRunnerÚ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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.
    c                 C   s   d S ©Nr   ©Úselfr   r   r   Údebug(   s   zImportErrorsTests.debugÚ_testImportErrorsc                 G   s   t d|  ¡ g|¢R Ž S )Nz--temp-directory)r   Úmktemp)r   r   r   r   r   r   -   s   zImportErrorsTests.runTrialc                 C   s   t |ƒ |S r   )Úprint)r   Ústuffr   r   r   Ú_print0   s   zImportErrorsTests._printc                    ó    t ƒ j||g|¢R i |¤Ž |S r   )ÚsuperÚassertIn©r   Ú	containerÚ	containeer   Úkwargs©Ú	__class__r   r   r%   4   ó   zImportErrorsTests.assertInc                    r#   r   )r$   ÚassertNotInr&   r*   r   r   r-   9   r,   zImportErrorsTests.assertNotInc                 C   s   |   ¡  d S r   )r   r   r   r   r   Útest_trialRun>   s   zImportErrorsTests.test_trialRunc                 C   s&   |   d¡}|  |d¡ |  |d¡ |S )Nztwisted.doesntexistú[ERROR]©r   r%   ©r   Údr   r   r   Útest_nonexistentModuleA   s   
z(ImportErrorsTests.test_nonexistentModulec                 C   ó2   |   d¡}|  |d¡ |  |d¡ |  |d¡ |S )NÚdoesntexistÚModuleNotFoundr/   r0   r1   r   r   r   Útest_nonexistentPackageG   ó
   
z)ImportErrorsTests.test_nonexistentPackagec                 C   r4   )Nzdoesntexist.barneyÚObjectNotFoundr/   r0   r1   r   r   r   Ú!test_nonexistentPackageWithModuleN   r8   z3ImportErrorsTests.test_nonexistentPackageWithModulec                 C   ó2   |   d¡}|  |d¡ |  |d¡ |  |d¡ |S )NÚ
badpackager/   ÚIOError©r   r%   r-   r1   r   r   r   Útest_badpackageU   r8   z!ImportErrorsTests.test_badpackagec                 C   r;   )Nzbadpackage.test_moduler/   r=   r>   r1   r   r   r   Útest_moduleInBadpackage\   r8   z)ImportErrorsTests.test_moduleInBadpackagec                 C   ó>   |   d¡}|  |d¡ |  |d¡ |  |d¡ |  |d¡ |S )Nzpackage.test_bad_moduler/   r=   ú<module r>   r1   r   r   r   Útest_badmodulec   ó   
z ImportErrorsTests.test_badmodulec                 C   rA   )Nzpackage.test_import_moduler/   r=   rB   r>   r1   r   r   r   Útest_badimportk   rD   z ImportErrorsTests.test_badimportc                 C   sJ   |   d¡}|  |d¡ |  |d¡ |  |d¡ |  |d¡ |  |d¡ |S )NÚpackager/   Útest_bad_moduleÚtest_import_modulerB   r=   r>   r1   r   r   r   Útest_recurseImports   s   
z$ImportErrorsTests.test_recurseImportc                 C   sV   |   d¡}|  |d¡ |  |d¡ |  |d¡ |  |t¡ |  |d¡ |  |d¡ |S )NÚpackage2r/   Útest_modulerB   r=   ©r   r%   Ú_noModuleErrorr-   r1   r   r   r   Útest_recurseImportErrors|   s   
z*ImportErrorsTests.test_recurseImportErrorsc                 C   s4   |   dd¡}|  |d¡ |  |t¡ |  |d¡ |S )Nz-NrJ   r/   rB   rL   r1   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%   r1   r   r   r   Útest_regularRun   rD   z!ImportErrorsTests.test_regularRunc                 C   óX   |   | j¡ |  tj | jdd¡¡}|  |d¡ |  |d¡ |  |d¡ |  |d¡ |S )NrF   ztest_module.pyr/   r=   rP   rQ   ©	ÚmangleSysPathÚoldPathr   ÚosÚpathÚjoinÚparentr-   r%   r1   r   r   r   Útest_filename•   s   zImportErrorsTests.test_filenamec                 C   rS   )NrF   ztest_dos_module.pyr/   r=   rP   rQ   rT   r1   r   r   r   Útest_dosFilež   s   zImportErrorsTests.test_dosFile)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   rZ   r   r"   r%   r-   r.   r3   r7   r:   r?   r@   rC   rE   rI   rN   rO   rR   r[   r\   Ú__classcell__r   r   r*   r   r   #   s,    	
	r   )r`   rW   Úior   Útwisted.scriptsr   r	   r   Útwisted.trial.testr   rM   r   ÚSysPathManglingTestr   r   r   r   r   Ú<module>   s   