%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/twisted/trial/test/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/twisted/trial/test/__pycache__/test_loader.cpython-312.pyc

�

Ϫ�f�_����dZddlmZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZmZmZddlmZmZmZdd	lmZdd
lmZmZddlmZmZmZddlmZdd
l m!Z!m"Z"mZddl#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*erddl+m,Z,d d�Z-Gd�de(j\�Z/d!d�Z0Gd�de(j\�Z1Gd�de(j\�Z2Gd�de2�Z3Gd�de(j\�Z4y)"z"
Tests for loading tests by name.
�)�annotationsN)�md5)�
attrgetter)�
ModuleType)�
TYPE_CHECKING�Callable�	Generator)�assert_that�equal_to�has_properties)�Matcher)�filepath�util)�PythonAttribute�PythonModule�	getModule)�ModuleNotFound)�reporter�runner�unittest)�
_iterateTests)�	ITestCase)�packages�)�after)�SupportsRichComparisonc�h�g}t|�D]!}|j|j���#|S)zI
    Return the id of each test within the given test suite or case.
    )r�append�id)�tests�names�tests   �@/usr/lib/python3/dist-packages/twisted/trial/test/test_loader.py�	testNamesr$!s4��
�E��e�$� ��
���T�W�W�Y�� ��L�c�@��eZdZd�fd�Zdd�Zdd�Zdd�Zdd�Z�xZS)�FinderPy3Testsc�T��t�|��tj�|_y�N)�super�setUpr�
TestLoader�loader)�self�	__class__s �r#r+zFinderPy3Tests.setUp,s���
��
���'�'�)��r%c�Z�|jt|jjd�y)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-�
findByName�r.s r#�test_findNonModulez!FinderPy3Tests.test_findNonModule0s$��	
����D�K�K�2�2�4T�	
r%c�Z�|jt|jjd�y)N�	nonextant)r1rr-r3r4s r#�test_findNonPackagez"FinderPy3Tests.test_findNonPackage:s�����.�$�+�+�*@�*@�+�Nr%c��tjtd�}|jt|j
j|�y)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__r1�
ValueErrorr-r3)r.�paths  r#�test_findNonFilezFinderPy3Tests.test_findNonFile=s1��
�|�|�H�&6�7�����*�d�k�k�&<�&<�d�Cr%c�Z�|jt|jjd�y)zn
        findByName will re-raise ImportErrors inside modules that it has found
        and imported.
        zunimportablepackage.test_moduleN)r1�ImportErrorr-r3r4s r#�test_findFileWithImportErrorz+FinderPy3Tests.test_findFileWithImportErrorEs$��
	
�������/�/�1R�	
r%��return�None)	�__name__�
__module__�__qualname__r+r5r8r>rA�
__classcell__)r/s@r#r'r'+s���*�
�O�D�
r%r'c�
�|j}|�J�tt|j�t	t
jttj|j���d��}t	td�|�S)a
    Match a module with a L{ModuleSpec} like that of the given module.

    @return: A matcher for a module spec that has the same name and origin as
        the given module spec, though the origin may be structurally inequal
        as long as it is semantically equal.
    )�name�origin�__spec__)	rLrrrJrr�FilePathrKr)�module�expected�
match_specs   r#�looselyResemblesrQOsr�����H�������X�]�]�+���!�!���*�*�8�?�?�;�<��	
��J���J�'��4�4r%c�X�eZdZdZdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z	dd�Z
dd	�Zdd
�Zy)
�	FileTestsz/
    Tests for L{runner.filenameToModule}.
    c��|jttjd�}|j	t|�d�y)zo
        L{runner.filenameToModule} raises a C{ValueError} when a non-existing
        file is passed.
        �itz'it' doesn't existN)r1r<r�filenameToModule�assertEqual�str)r.�errs  r#�test_notFilezFileTests.test_notFilels3��
���
�F�,C�,C�T�J������S��#7�8r%c��tjtjtd��}ddlm}|j||�y)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)rrVrr:r;�twisted.trial.testr]rW�r.�sample1�sample2s   r#�test_moduleInPathzFileTests.test_moduleInPathts2��
�)�)�$�,�,�x��*M�N��8�����'�*r%c��|j|j�tjtj
j
|jdd��}|j|jd�|j�|j|j�ddlm
}|j||�t|t!|��y)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�oldPathrrV�osr=�join�parentrWrE�cleanUpModules�newPathrdre�assertIsNotr
rQr_s   r#�test_moduleNotInPathzFileTests.test_moduleNotInPath~s���	
���4�<�<�(��)�)��G�G�L�L����m�5E�F�
��	
����)�)�+D�E��������4�<�<�(�6�����'�*��G�-�g�6�7r%c���tjtjj	|j
d��}|j
|tjd�y)z�
        If the file in question is a package on the Python path, then it should
        properly import and return that package.
        rdN)	rrVrhr=rirj�assertIs�sys�modules)r.�package1s  r#�test_packageInPathzFileTests.test_packageInPath�s>��
�*�*�2�7�7�<�<����]�+S�T���
�
�h����M� :�;r%c��|j|j�tjtj
j
|jd��}|j|jd�|j�|j|j�ddl}|j||�t|t|��y)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.
        rdrN)rfrgrrVrhr=rirjrWrErkrlrdrmr
rQ)r.rsrds   r#�test_packageNotInPathzFileTests.test_packageNotInPath�s���	
���4�<�<�(��*�*�2�7�7�<�<����]�+S�T������*�*�M�:��������4�<�<�(������;�/��H�.�{�;�<r%c�.�tj|j�jd�}|j	�|jttj|j�}|jt|�|j�d��y)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)rrMrj�child�createDirectoryr1r<rrVr=rWrX)r.�emptyDirrYs   r#�test_directoryNotPackagez"FileTests.test_directoryNotPackage�so���$�$�T�[�[�1�7�7�8H�I��� � �"����
�F�,C�,C�X�]�]�S������S��h�m�m�%6�6Q�#R�Sr%c���tj|j�jd�}|j	d�|jttj|j�y)zn
        L{runner.filenameToModule} raises a C{SyntaxError} when a non-Python
        file is passed.
        �	notpythonsThis isn't pythonN)
rrMrjry�
setContentr1�SyntaxErrorrrVr=)r.�filenames  r#�test_filenameNotPythonz FileTests.test_filenameNotPython�sN��
�$�$�T�[�[�1�7�7��D�����0�1����+�v�'>�'>��
�
�Nr%c��tj|j�jd�}|j	t
jjd��	tj|j�}|j|j|j�|j�y#|j�wxYw)zX
        The C{__file__} attribute of the module should match the package name.
        zgoodpackage.py�utf8N)rrMrjryrr�
testModule�encoderrVr=rWr;�remove)r.r�rNs   r#�test_filenameMatchesPackagez%FileTests.test_filenameMatchesPackage�s����$�$�T�[�[�1�7�7�8H�I�����H�/�/�6�6�v�>�?�	��,�,�X�]�]�;�F����X�]�]�F�O�O�<��O�O���H�O�O��s
�AB4�4Cc�f�tj|j�jd�}|j	�|jd�jd�	t
j|j�}|j|jjd��t
j|jtjjz�}|j|jjd��|j�y#|j�wxYw)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__.pyr%N)rrMrjryrzrrrVr=�
assertTruerE�endswithrh�sepr�)r.�goodDirrNs   r#�test_directoryzFileTests.test_directory�s���
�#�#�D�K�K�0�6�6��G�����!��
�
�m�$�/�/��4�	��,�,�W�\�\�:�F��O�O�F�O�O�4�4�_�E�F��,�,�W�\�\�B�G�G�K�K�-G�H�F��O�O�F�O�O�4�4�_�E�F��N�N���G�N�N��s
� B-D�D0NrB)
rErFrG�__doc__rZrbrnrtrvr|r�r�r��r%r#rSrSgs6���9�+�8�*<�=�$
T�O��r%rSc��eZdZdZd"d�Zd"d�Zd"d�Zd"d�Zd"d�Zd"d�Z	d"d�Z
d"d	�Zd"d
�Zd"d�Z
d"d�Zd"d
�Zd"d�Zd"d�Zd"d�Zd"d�Zd"d�Zd"d�Zd"d�Zd"d�Zd"d�Zd"d�Zd"d�Zd"d�Zd"d�Zd"d�Z						d#d�Zd"d�Zd"d�Z d"d�Z!d"d �Z"y!)$�LoaderTestsz(
    Tests for L{trial.TestLoader}.
    c�t�tj�|_tjj|�yr))rr,r-r�SysPathManglingTestr+r4s r#r+zLoaderTests.setUp�s&���'�'�)����$�$�*�*�4�0r%c���ddlm}|jj|j�}|jgd�|jD�cgc]}|j��c}�gd�}tt|td�����fd�|j_|jj|j�}|j||jD�cgc]}|j��c}�ycc}wcc}w)Nrr\)�test_a�test_b�test_c)r�r�r��c�D���j|j�d�S)N���)�get�shortDescription)�x�sortDicts �r#�<lambda>z,LoaderTests.test_sortCases.<locals>.<lambda>�s���x�|�|�A�4F�4F�4H�"�'M�r%)r^r]r-�	loadClass�AlphabetTestrW�_tests�_testMethodName�dict�zip�range�sorter)r.r]�suiter"�newOrderr�s     @r#�test_sortCaseszLoaderTests.test_sortCases�s����-����%�%�f�&9�&9�:�����*�.3�l�l�;�d�T�
!�
!�;�	
�2����H�e�A�h�/�0��M��������%�%�f�&9�&9�:������U�\�\�#R�T�D�$8�$8�#R�S��

<��$Ss�	C3
�C8
c��|jjd�}tj�}|j	|�|j|jd�|jt|j�d�y)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_failrN)	r-�
loadByNamer�
TestResult�runrW�testsRun�len�failures)r.r��results   r#�test_loadFailurezLoaderTests.test_loadFailure�sd��
���&�&�D�
���$�$�&��
�	�	�&��������!�,�����V�_�_�-�q�1r%c��ddlm}|jj|jj
|jgd���}|j
d|j��|j
d|j�y)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.
        rr\)r]�DecorationTest�test_badDecorator�rj�qualNamerr�N)	r^r]r-�loadAnythingr�r�rW�countTestCasesr��r.r]r�s   r#�test_loadBadDecoratorz!LoaderTests.test_loadBadDecoratorsm��	.����(�(��!�!�3�3��(�(�F�)�
��
	
����E�0�0�2�3����,�e�.C�.C�Dr%c��ddlm}|jj|jj
|jgd���}|j
d|j��|j
d|j�y)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.
        rr\)r]r��test_goodDecoratorr�rr�N)	r^r]r-r�r�r�rWr�r�r�s   r#�test_loadGoodDecoratorz"LoaderTests.test_loadGoodDecoratorsm��
	.����(�(��!�!�4�4��(�(�G�)�
��
	
����E�0�0�2�3����-�u�/D�/D�Er%c��ddlm}|jj|jj
|jgd���}|j
d|j��|j
d|j�y)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.
        rr\)r]r��test_renamedDecoratorr�rr�N)	r^r]r-r�r�r�rWr�r�r�s   r#�test_loadRenamedDecoratorz%LoaderTests.test_loadRenamedDecorator%sm��	.����(�(��!�!�7�7��(�(�J�)�
��
	
����E�0�0�2�3����0�%�2G�2G�Hr%c��ddlm}|jj|j�}|jd|j
��|jddg|jD�cgc]}|j��c}�ycc}w)Nrr\��test_bar�test_foo)	r^r]r-r��FooTestrWr�r�r�)r.r]r�r"s    r#�test_loadClasszLoaderTests.test_loadClass5sf��-����%�%�f�n�n�5������E�0�0�2�3����
��$����&U��t�';�';�&U�	
��&Us�(B
c��ddlm}|jt|jj
|�|jt|jj
|jj�|jt|jj
d�|jt|jj
d�y�Nrr\�string)�foo�bar)r^r]r1�	TypeErrorr-r�r�r��r.r]s  r#�test_loadNonClasszLoaderTests.test_loadNonClass>s��-����)�T�[�[�%:�%:�F�C����)�T�[�[�%:�%:�F�N�N�<S�<S�T����)�T�[�[�%:�%:�H�E����)�T�[�[�%:�%:�N�Kr%c�z�ddlm}|jt|jj
|j�y�Nrr\)r^r]r1r<r-r��NotATestr�s  r#�test_loadNonTestCasez LoaderTests.test_loadNonTestCaseFs%��-����*�d�k�k�&;�&;�V�_�_�Mr%c��ddlm}|jj|�}|j	d|j��y)Nrr\�
)r^r]r-�
loadModulerWr�r�s   r#�test_loadModulezLoaderTests.test_loadModuleKs2��-����&�&�v�.������U�1�1�3�4r%c��ddlm}|jt|jj
|j�|jt|jj
|jj�|jt|jj
d�|jt|jj
d�yr�)r^r]r1r�r-r�r�r�r�s  r#�test_loadNonModulezLoaderTests.test_loadNonModuleQs���-����)�T�[�[�%;�%;�V�^�^�L����)�T�[�[�%;�%;�V�^�^�=T�=T�U����)�T�[�[�%;�%;�X�F����)�T�[�[�%;�%;�^�Lr%c��ddl}|jj|�}|jd|j	��y�Nr��rdr-�loadPackagerWr��r.rdr�s   r#�test_loadPackagezLoaderTests.test_loadPackageYs2������'�'��4������E�0�0�2�3r%c��ddlm}|jt|jj
|j�|jt|jj
|jj�|jt|jj
d�|jt|jj
d�yr�)r^r]r1r�r-r�r�r�r�s  r#�test_loadNonPackagezLoaderTests.test_loadNonPackage_s���-����)�T�[�[�%<�%<�f�n�n�M����)�T�[�[�%<�%<�f�n�n�>U�>U�V����)�T�[�[�%<�%<�h�G����)�T�[�[�%<�%<�n�Mr%c�f�ddlm}|jt|jj
|�yr�)r^r]r1r�r-r�r�s  r#�test_loadModuleAsPackagez$LoaderTests.test_loadModuleAsPackagegs#��-�	
���)�T�[�[�%<�%<�f�Er%c��ddl}|jj|d��}|jd|j	��y�NrT��recurse�r�r�s   r#�test_loadPackageRecursivez%LoaderTests.test_loadPackageRecursivems7������'�'��T�'�B������U�1�1�3�4r%c���ddlm}|jj|�}|j	|j
|jdjdjj�yr�)	r^r]r-r�rWrEr�r/rFr�s   r#�test_loadAnythingOnModulez%LoaderTests.test_loadAnythingOnModulessO��-����(�(��0������O�O�U�\�\�!�_�3�3�A�6�@�@�K�K�	
r%c��ddlm}|jj|j�}|jd|j
��y)Nrr\r�)r^r]r-r�r�rWr�r�s   r#�test_loadAnythingOnClassz$LoaderTests.test_loadAnythingOnClass{s6��-����(�(����8������E�0�0�2�3r%c���ddl}|jj|�}|jt	||jj
��|j
d|j��yr��rdr-r�r��
isinstance�suiteFactoryrWr�r�s   r#�test_loadAnythingOnPackagez&LoaderTests.test_loadAnythingOnPackage�sO������(�(��5�����
�5�$�+�+�*B�*B�C�D�����E�0�0�2�3r%c���ddl}|jj|d��}|jt	||jj
��|j
d|j��yr�r�r�s   r#�#test_loadAnythingOnPackageRecursivez/LoaderTests.test_loadAnythingOnPackageRecursive�sT������(�(��d�(�C�����
�5�$�+�+�*B�*B�C�D�����U�1�1�3�4r%c�Z�|jt|jjd�y)Nrd)r1r�r-r�r4s r#�test_loadAnythingOnStringz%LoaderTests.test_loadAnythingOnString�s ��	
���)�T�[�[�%=�%=�}�Mr%c���ddl}|jj|d��}tj�}|j|�|j
d|j��|j
dt|j��|jD��cgc]\}}|j���}}}|j�|j
|ddg�ycc}}w)NrTr�Fr�zpackage.test_bad_modulezpackage.test_import_module)�packager-r�r�Reporterr�rW�
wasSuccessfulr��errorsr�sort)r.r�r�r�r"�errorrs       r#�test_importErrorszLoaderTests.test_importErrors�s�������'�'���'�>���"�"�$��
�	�	�&������� 4� 4� 6�7�����C��
�
�.�/�/5�}�}�=���e�$�'�'�)�=��=����
�����.�0L�M�	
��>s�Cc���Gd�dtj�}|jj|�}t	j
�}|j
|�|j|j��y)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��eZdZdd�Zdd�Zy)�>LoaderTests.test_differentInstances.<locals>.DistinctInstancesc��d|_y)N�test1Run)�firstr4s r#�test_1zELoaderTests.test_differentInstances.<locals>.DistinctInstances.test_1�s	��'��
r%c�:�|jt|d��y)Nr	)�assertFalse�hasattrr4s r#�test_2zELoaderTests.test_differentInstances.<locals>.DistinctInstances.test_2�s��� � ���w�!7�8r%NrB)rErFrGr
rr�r%r#�DistinctInstancesr�s��
(�
9r%rN)	�pyunit�TestCaser-r�rr�r�r�r�)r.rr�r�s    r#�test_differentInstancesz#LoaderTests.test_differentInstances�sX��	9����	9����%�%�&7�8���"�"�$��
�	�	�&������,�,�.�/r%c��ddlm}|jj|�}|j	d|j��|j	dt
|dd��y)zp
        Check that C{test_suite} is used when present and other L{TestCase}s are
        not included.
        r)�mockcustomsuite�
MyCustomSuiterJN)r^rr-r�rWr��getattr)r.rr�s   r#�test_loadModuleWith_test_suitez*LoaderTests.test_loadModuleWith_test_suite�sM��
	7����&�&��7������E�0�0�2�3�����'�%���*F�Gr%c��ddlm}|jj|�}|j	d|j��|j	dt
|dd��y)zo
        Check that C{testSuite} is used when present and other L{TestCase}s are
        not included.
        r��mockcustomsuite2rrJN)r^rr-r�rWr�r)r.rr�s   r#�test_loadModuleWith_testSuitez)LoaderTests.test_loadModuleWith_testSuite�sN��
	8����&�&�'7�8������E�0�0�2�3�����'�%���*F�Gr%c��ddlm}|jj|�}|j	dt|dd��y)z�
        Check that if C{testSuite} and C{test_suite} are both present in a
        module then C{testSuite} gets priority.
        r)�mockcustomsuite3�	testSuiterJN)r^rr-r�rWr)r.rr�s   r#�test_loadModuleWithBothCustomz)LoaderTests.test_loadModuleWithBothCustom�s5��
	8����&�&�'7�8������g�e�V�T�&B�Cr%c��dd�}ddlm}||jc|_}	|jt|j
j|�||_y#||_wxYw)zz
        Make sure that any C{AttributeError}s raised by C{testSuite} are not
        swallowed by L{TestLoader}.
        c��td��)Nzshould be reraised)r2r�r%r#rzBLoaderTests.test_customLoadRaisesAttributeError.<locals>.testSuite�s�� �!5�6�6r%rrNrB)r^rrr1r2r-r�)r.rr�originals    r#�#test_customLoadRaisesAttributeErrorz/LoaderTests.test_customLoadRaisesAttributeError�sX��	7�	8�09�;K�;U�;U�,��"�H�	2����n�d�k�k�.D�.D�FV�W�)1��&����&�s�+A�	Ac��t|�}t|�}|j�|j�|j||�yr))r$rrW)r.�test1�test2�names1�names2s     r#�assertSuitesEqualzLoaderTests.assertSuitesEqual�s:��
�5�!���5�!�����
����
������(r%c��d}|jj||gd�}|jj|d�}|j||�y)z@
        Check that loadByNames ignores duplicate names
        �twisted.trial.test.test_logTN)r-�loadByNamesr�r))r.rN�suite1�suite2s    r#�test_loadByNamesDuplicatez%LoaderTests.test_loadByNamesDuplicate�sJ��/�����(�(�&�&�)9�4�@�����'�'���5�����v�v�.r%c���gd�}|jj|�}tjt	|jj
|��}|j
t|�t|��y)zX
        L{TestLoader.loadByNames} preserves the order of tests provided to it.
        )�$inheritancepackage.test_x.A.test_fooztwisted.trial.test.samplerdr+z!twisted.trial.test.sample.FooTest�package.test_moduleN)r-r,r�	TestSuite�mapr�rWr$�r.rrr-r.s    r#�test_loadByNamesPreservesOrderz*LoaderTests.test_loadByNamesPreservesOrder�sZ��
�����(�(��1���!�!�#�d�k�k�&<�&<�g�"F�G������6�*�I�f�,=�>r%c���ddg}|jj|�}tjt	|jj
|��}|j
||�y)zM
        Check that loadByNames loads all the names that it is given
        rdr2N�r-r,rr3r4r�r)r5s    r#�test_loadDifferentNamesz#LoaderTests.test_loadDifferentNamessT��!�"7�8�����(�(��1���!�!�#�d�k�k�&<�&<�g�"F�G�����v�v�.r%c���ddg}|jj|�}tjt	|jj
|��}|j
||�y)zu
        Check that test methods names which are inherited from are all
        loaded rather than just one.
        r1z$inheritancepackage.test_x.B.test_fooNr8)r.�methodsr-r.s    r#�test_loadInheritedMethodsz%LoaderTests.test_loadInheritedMethodssX��
3�2�
�����(�(��1���!�!�#�d�k�k�&<�&<�g�"F�G�����v�v�.r%NrB)r%�"pyunit.TestCase | pyunit.TestSuiter&r=rCrD)#rErFrGr�r+r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr#r)r/r6r9r<r�r%r#r�r��s����1�T�2�E� 
F�I� 
�L�N�
5�M�4�N�F�5�
�4�4�5�N�

�0�&	H�	H�D�2�$	)�1�	)�2�	)�
�		)�/�?� /�/r%r�c��eZdZdd�Zy)�ZipLoadingTestsc��ddlm}tj|�||j|jdz�|xjdz
c_|j|j|jgz�y)Nr)�zipitz.zip)� twisted.python.test.test_zippathrAr�r+rjrfrg)r.rAs  r#r+zZipLoadingTests.setUp#sU��:����$��
�d�k�k�4�;�;��/�0����v������4�<�<�4�;�;�-�7�8r%NrB)rErFrGr+r�r%r#r?r?"s��9r%r?c�Z�eZdZdd�Z				dd�Zejf			d	d�Zdd�Zdd�Z	y)
�PackageOrderingTestsc���tj�|_|j�|_t
jj|jd�}tj|�tt
jj|d�d�j�tjj||�|j|j|jgz�y)N�uberpackager��wb)rr,r-�mktemp�topDirrhr=ri�makedirs�open�closerr�r+rfrg)r.rjs  r#r+zPackageOrderingTests.setUp-s����'�'�)����k�k�m��������d�k�k�=�9��
���F���R�W�W�\�\�&�-�
0�$�7�=�=�?��$�$�*�*�4��8����4�<�<�4�;�;�-�7�8r%c#��K�td�}g}|j�D]A}|jjd�dj	d�s�1|j|��Ct
||��}|D]�}|jd�}|�|���g}|j�D]7}	tj|	j��s�'|j|	��9t
||��}
|
D]o}g}|j�D]A}
|
jjd�dj	d�s�1|j|
��Ct
||��}|Ed{����q��y7�	�w)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.
        rF�.r��test_)�keyNr")r�walkModulesrJ�split�
startswithr�sorted�load�iterAttributesr�
isTestCase)r.r��pkg�testModulesr��
sortedModules�modinforN�testClasses�attrib�
sortedClasses�clsinfo�testMethods�attr�
sortedMethodss               r#�_trialSortAlgorithmz(PackageOrderingTests._trialSortAlgorithm6sU����(�
�&�����/�/�+�	/�J����$�$�S�)�"�-�8�8��A��"�"�:�.�	/��{��7�
�$�	-�G��\�\�$�'�F��~��
� ��%�4�4�6�3�F��(�(�����7�#�*�*�6�2�3�!'�{�� ?�
�,�-�G�"$�K� '� 6� 6� 8�5���9�9�?�?�3�/��3�>�>�v�F�'�.�.�t�4�5�%+�;�F�$C�M�,�,�,�
-�	-�"-�s&�AE �A5E �A'E �/%E �E�
E c
��ddl}||j_|jj|d��}t	j
|t�}tt|��}t|j|��}tt||��D]Q\}\}}|j|j|j�d||j|j�fz��S|jt|�t|��y)zG
        Verify that packages are loaded in the correct order.
        rNTr�z
#%d: %s != %s)rFr-r�r�r�decorater�listrrc�	enumerater�rWrJrr�)	r.r�rFr��resultingTests�manifest�number�manifestTest�
actualTests	         r#�loadSortedPackagesz'PackageOrderingTests.loadSortedPackagescs���	�#��������'�'��T�'�B���!�!�%��3���m�E�2�3����0�0��8�9��2;���.�)�3
�	�.�F�.�\�:�
����!�!��
�
���6�<�+<�+<�j�m�m�o�"N�N�
�	�	
����X���N�(;�<r%c�$�|j�yr)�rmr4s r#�test_sortPackagesDefaultOrderz2PackageOrderingTests.test_sortPackagesDefaultOrder|s�����!r%c�.�dd�}|j|�y)Nc��tj|�}t|jd��j	�}|S)Nr�)rrJrr��	hexdigest)�s�n�ds   r#�sillySorterzEPackageOrderingTests.test_sortPackagesSillyOrder.<locals>.sillySorter�s2��
���A��A��A�H�H�V�$�%�/�/�1�A��Hr%)rtzrunner._LoadablerCrXro)r.rws  r#�test_sortPackagesSillyOrderz0PackageOrderingTests.test_sortPackagesSillyOrders��	�	
����,r%NrB)r�zBCallable[[PythonModule | PythonAttribute], SupportsRichComparison]rCz5Generator[PythonModule | PythonAttribute, None, None])r�z4Callable[[runner._Loadable], SupportsRichComparison]rCrD)
rErFrGr+rcrrJrmrprxr�r%r#rDrD,sG��9�+-�X�+-�	>�+-�\NT�[�[�=�J�=�	
�=�2"�
-r%rD)r r=rCz	list[str])rNrrCzMatcher[ModuleType])5r��
__future__rrhrqrr�hashlibr�operatorr�typesr�typingrrr	�hamcrestr
rr�hamcrest.core.matcherr
�twisted.pythonrr�twisted.python.modulesrrr�twisted.python.reflectr�
twisted.trialrr�twisted.trial._asyncrunnerr�twisted.trial.itrialrr^r�matchersr�	_typeshedrr$r�r'rQrSr�r?rDr�r%r#�<module>r�s����#�	�
�����5�5�:�:�)�)�K�K�1�4�4�4�*�'���0��!
�X�1�1�!
�H5�0x��,�,�x�v}/�(�.�.�}/�@
9�k�9�]-�8�7�7�]-r%

Zerion Mini Shell 1.0