
    Vh                        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Z G d dej"                        Zy)z*
Tests for the output generated by trial.
    )annotationsN)StringIO)TypeVar)trial)runner)packages_TzNo module named 'frotz'c                 "   ddl m} t        j                         }|j	                  |        t               }t        j                  |j                  ||d         }t        j                  |      }|j                  |       |j                         S )Nr   )reporterztemp-directory)streamworkingDirectory)twisted.trialr   r   OptionsparseOptionsr   r   TrialRunnerVerboseTextReporter	_getSuiterungetvalue)argsr   configoutputmyRunnersuites         N/home/dcms/DCMS/lib/python3.12/site-packages/twisted/trial/test/test_output.pyrunTrialr      ss    &]]_F
ZF!!$$ 01H
 OOF#ELL??    c                       e Zd ZdZddZdZddZddZ	 	 	 	 	 	 	 	 	 	 d fdZ	 	 	 	 	 	 	 	 	 	 d f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 xZS )ImportErrorsTestszbActually run trial as if on the command line and check that the output
    is what we expect.
    c                     y N selfs    r   debugzImportErrorsTests.debug+   s    r   _testImportErrorsc                8    t        d| j                         g| S )Nz--temp-directory)r   mktemp)r$   r   s     r   r   zImportErrorsTests.runTrial0   s    *DKKMADAAr   c                    t        |       |S r!   )print)r$   stuffs     r   _printzImportErrorsTests._print3   s    er   c                0    t        |   ||g|i | |S r!   )superassertInr$   	container	containeer   kwargs	__class__s        r   r/   zImportErrorsTests.assertIn7   s$     	I???r   c                0    t        |   ||g|i | |S r!   )r.   assertNotInr0   s        r   r6   zImportErrorsTests.assertNotIn>   s$     	IyB4B6Br   c                $    | j                          y r!   )r   r#   s    r   test_trialRunzImportErrorsTests.test_trialRunE   s    r   c                p    | j                  d      }| j                  |d       | j                  |d       |S )Nztwisted.doesntexist[ERROR]r   r/   r$   ds     r   test_nonexistentModulez(ImportErrorsTests.test_nonexistentModuleH   s3    MM/0a#a./r   c                    | j                  d      }| j                  |d       | j                  |d       | j                  |d       |S )NdoesntexistModuleNotFoundr:   r;   r<   s     r   test_nonexistentPackagez)ImportErrorsTests.test_nonexistentPackageN   s@    MM-(a'a)*a#r   c                    | j                  d      }| j                  |d       | j                  |d       | j                  |d       |S )Nzdoesntexist.barneyObjectNotFoundr:   r;   r<   s     r   !test_nonexistentPackageWithModulez3ImportErrorsTests.test_nonexistentPackageWithModuleU   sB    MM./a-.a)*a#r   c                    | j                  d      }| j                  |d       | j                  |d       | j                  |d       |S )N
badpackager:   IOErrorr   r/   r6   r<   s     r   test_badpackagez!ImportErrorsTests.test_badpackage\   sA    MM,'a#a&I&r   c                    | j                  d      }| j                  |d       | j                  |d       | j                  |d       |S )Nzbadpackage.test_moduler:   rH   rI   r<   s     r   test_moduleInBadpackagez)ImportErrorsTests.test_moduleInBadpackagec   sC    MM23a#a12I&r   c                    | j                  d      }| j                  |d       | j                  |d       | j                  |d       | j                  |d       |S )Nzpackage.test_bad_moduler:   rH   <module rI   r<   s     r   test_badmodulez ImportErrorsTests.test_badmodulej   sS    MM34a#a23I&J'r   c                    | j                  d      }| j                  |d       | j                  |d       | j                  |d       | j                  |d       |S )Nzpackage.test_import_moduler:   rH   rN   rI   r<   s     r   test_badimportz ImportErrorsTests.test_badimportr   sS    MM67a#a56I&J'r   c                    | j                  d      }| j                  |d       | j                  |d       | j                  |d       | j                  |d       | j                  |d       |S )Npackager:   test_bad_moduletest_import_modulerN   rH   rI   r<   s     r   test_recurseImportz$ImportErrorsTests.test_recurseImportz   sa    MM)$a#a*+a-.J'I&r   c                   | j                  d      }| j                  |d       | j                  |d       | j                  |d       | j                  |t               | j                  |d       | j                  |d       |S )Npackage2r:   test_modulerN   rH   r   r/   _noModuleErrorr6   r<   s     r   test_recurseImportErrorsz*ImportErrorsTests.test_recurseImportErrors   sm    MM*%a#a$a'a(J'I&r   c                    | j                  dd      }| j                  |d       | j                  |t               | j                  |d       |S )Nz-NrX   r:   rN   rZ   r<   s     r   test_nonRecurseImportErrorsz-ImportErrorsTests.test_nonRecurseImportErrors   sC    MM$
+a#a(J'r   c                    | j                  d      }| j                  |d       | j                  |d       | j                  |d       | j                  |d       |S )Nzpackage.test_moduler:   rH   OKPASSED (successes=1))r   r6   r/   r<   s     r   test_regularRunz!ImportErrorsTests.test_regularRun   sS    MM/0I&I&aa/0r   c                @   | j                  | j                         | j                  t        j                  j                  | j                  dd            }| j                  |d       | j                  |d       | j                  |d       | j                  |d       |S )NrS   ztest_module.pyr:   rH   r`   ra   	mangleSysPatholdPathr   ospathjoinparentr6   r/   r<   s     r   test_filenamezImportErrorsTests.test_filename   sz    4<<(MM"'',,t{{I?OPQI&I&aa/0r   c                @   | j                  | j                         | j                  t        j                  j                  | j                  dd            }| j                  |d       | j                  |d       | j                  |d       | j                  |d       |S )NrS   ztest_dos_module.pyr:   rH   r`   ra   rd   r<   s     r   test_dosFilezImportErrorsTests.test_dosFile   sz    4<<(MM"'',,t{{I?STUI&I&aa/0r   )returnNoner   strrn   rq   )r+   r	   rn   r	   )
r1   rq   r2   rq   r   objectr3   rr   rn   rq   )rn   rq   )__name__
__module____qualname____doc__r%   rj   r   r,   r/   r6   r8   r>   rB   rE   rJ   rL   rO   rQ   rV   r\   r^   rb   rk   rm   __classcell__)r4   s   @r   r   r   &   s     !FB),5;GM	),5;GM	r   r   rp   )rv   
__future__r   rg   ior   typingr   twisted.scriptsr   r   r   twisted.trial.testr   r	   r[   r   SysPathManglingTestr   r"   r   r   <module>r~      sH    # 	   !   'T]* G44 Gr   