HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/test/__pycache__/test_reflect.cpython-38.pyc
U


W[�e�@s�dZddlmZmZddlZddlZddlmZddlm	Z	ddl
mZddlm
ZddlmZdd	lmZmZmZmZmZGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd�de!e"�Z#e#d e!fd!d!d"��Z$Gd#d$�d$e!�Z%Gd%d&�d&e�Z&Gd'd(�d(e�Z'Gd)d*�d*e�Z(Gd+d,�d,e�Z)Gd-d.�d.ej�Z*Gd/d0�d0ej�Z+dS)1z6
Test cases for the L{twisted.python.reflect} module.
�)�division�absolute_importN)�deque)�_PY3)�unittest)�SynchronousTestCase)�reflect)�accumulateMethods�prefixedMethods�prefixedMethodNames�addMethodNamesToDict�fullyQualifiedNamec@seZdZdZdd�ZdS)�Basez`
    A no-op class which can be used to verify the behavior of
    method-discovering APIs.
    cCsdS)z9
        A no-op method which can be discovered.
        N���selfrr�;/usr/lib/python3/dist-packages/twisted/test/test_reflect.py�methodszBase.methodN)�__name__�
__module__�__qualname__�__doc__rrrrrrsrc@seZdZdZdS)�SubzF
    A subclass of a class with a method which can be discovered.
    N)rrrrrrrrr$src@s eZdZdZdd�Zdd�ZdS)�Separatez=
    A no-op class with methods with differing prefixes.
    cCsdS)zJ
        A no-op method which a matching prefix to be discovered.
        Nrrrrr�good_method0szSeparate.good_methodcCsdS)zO
        A no-op method with a mismatched prefix to not be discovered.
        Nrrrrr�
bad_method6szSeparate.bad_methodN)rrrrrrrrrrr+src@s(eZdZdZdd�Zdd�Zdd�ZdS)	�AccumulateMethodsTestszt
    Tests for L{accumulateMethods} which finds methods on a class hierarchy and
    adds them to a dictionary.
    cCs*t�}i}t||�|�d|ji|�dS)z�
        If x is and instance of Base and Base defines a method named method,
        L{accumulateMethods} adds an item to the given dictionary with
        C{"method"} as the key and a bound method object for Base.method value.
        rN)rr	�assertEqualr�r�x�outputrrr�
test_ownClassCs
z$AccumulateMethodsTests.test_ownClasscCs*t�}i}t||�|�d|ji|�dS)a
        If x is an instance of Sub and Sub is a subclass of Base and Base
        defines a method named method, L{accumulateMethods} adds an item to the
        given dictionary with C{"method"} as the key and a bound method object
        for Base.method as the value.
        rN)rr	rrrrrr�test_baseClassOs
z%AccumulateMethodsTests.test_baseClasscCs,t�}i}t||d�|�d|ji|�dS)z�
        If a prefix is given, L{accumulateMethods} limits its results to
        methods beginning with that prefix.  Keys in the resulting dictionary
        also have the prefix removed from them.
        �good_rN)rr	rrrrrr�test_prefix\sz"AccumulateMethodsTests.test_prefixN)rrrrr!r"r$rrrrr=s
rc@s eZdZdZdd�Zdd�ZdS)�PrefixedMethodsTestszr
    Tests for L{prefixedMethods} which finds methods on a class hierarchy and
    adds them to a dictionary.
    cCs"t�}t|�}|�|jg|�dS)zc
        L{prefixedMethods} returns a list of the methods discovered on an
        object.
        N)rr
rrrrrr�test_onlyObjectosz$PrefixedMethodsTests.test_onlyObjectcCs$t�}t|d�}|�|jg|�dS)zo
        If a prefix is given, L{prefixedMethods} returns only methods named
        with that prefix.
        r#N)rr
rrrrrrr$ys
z PrefixedMethodsTests.test_prefixN)rrrrr&r$rrrrr%is
r%c@s eZdZdZdd�Zdd�ZdS)�PrefixedMethodNamesTestsz+
    Tests for L{prefixedMethodNames}.
    cCs|�dgttd��dS)z�
        L{prefixedMethodNames} returns a list including methods with the given
        prefix defined on the class passed to it.
        rr#N)rrrrrrr�test_method�sz$PrefixedMethodNamesTests.test_methodcCs(Gdd�dt�}|�dgt|d��dS)z�
        L{prefixedMethodNames} returns a list included methods with the given
        prefix defined on base classes of the class passed to it.
        c@seZdZdS)z<PrefixedMethodNamesTests.test_inheritedMethod.<locals>.ChildN�rrrrrrr�Child�sr*rr#N)rrr)rr*rrr�test_inheritedMethod�sz-PrefixedMethodNamesTests.test_inheritedMethodN)rrrrr(r+rrrrr'�sr'c@seZdZdZdd�ZdS)�AddMethodNamesToDictTestsz,
    Tests for L{addMethodNamesToDict}.
    cCsHGdd�dt�}Gdd�dt|�}i}t||d|�|�ddi|�dS)	z�
        If C{baseClass} is passed to L{addMethodNamesToDict}, only methods which
        are a subclass of C{baseClass} are added to the result dictionary.
        c@seZdZdS)z;AddMethodNamesToDictTests.test_baseClass.<locals>.AlternateNr)rrrr�	Alternate�sr-c@seZdZdd�ZdS)z7AddMethodNamesToDictTests.test_baseClass.<locals>.ChildcSsdS�Nrrrrr�good_alternate�szFAddMethodNamesToDictTests.test_baseClass.<locals>.Child.good_alternateN)rrrr/rrrrr*�sr*r#Z	alternate�N)�objectrrr)rr-r*�resultrrrr"�s
z(AddMethodNamesToDictTests.test_baseClassN)rrrrr"rrrrr,�sr,c@seZdZdZdd�ZdS)�Summerz9
    A class we look up as part of the LookupsTests.
    cCsdS)z
        Do something.
        Nrrrrr�	reallySet�szSummer.reallySetN)rrrrr4rrrrr3�sr3c@sxeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�LookupsTestszC
    Tests for L{namedClass}, L{namedModule}, and L{namedAny}.
    cCs|�t�d�t�dS)zY
        L{namedClass} should return the class object for the name it is passed.
        � twisted.test.test_reflect.SummerN)�assertIsrZ
namedClassr3rrrr�test_namedClassLookup�s�z"LookupsTests.test_namedClassLookupcCs"ddlm}|�t�d�|�dS)zc
        L{namedModule} should return the module object for the name it is
        passed.
        r��monkey�twisted.python.monkeyN)�twisted.pythonr:r7rZnamedModule�rr:rrr�test_namedModuleLookup�s
�z#LookupsTests.test_namedModuleLookupcCs ddl}|�t�d�|j�dS)zY
        L{namedAny} should return the package object for the name it is passed.
        rN�twisted.python)r<r7r�namedAny�python�r�twistedrrr�test_namedAnyPackageLookup�s
�z'LookupsTests.test_namedAnyPackageLookupcCs"ddlm}|�t�d�|�dS)zX
        L{namedAny} should return the module object for the name it is passed.
        rr9r;N)r<r:r7rr@r=rrr�test_namedAnyModuleLookup�s
�z&LookupsTests.test_namedAnyModuleLookupcCs|�t�d�t�dS)zW
        L{namedAny} should return the class object for the name it is passed.
        r6N)r7rr@r3rrrr�test_namedAnyClassLookup�s�z%LookupsTests.test_namedAnyClassLookupcCs|�t�d�tj�dS)z�
        L{namedAny} should return the object an attribute of a non-module,
        non-package object is bound to for the name it is passed.
        z*twisted.test.test_reflect.Summer.reallySetN)rrr@r3r4rrrr�test_namedAnyAttributeLookup�s��z)LookupsTests.test_namedAnyAttributeLookupcCs|�t�d�tjj�dS)z�
        L{namedAny} should return the object an attribute of an object which
        itself was an attribute of a non-module, non-package object is bound to
        for the name it is passed.
        z2twisted.test.test_reflect.Summer.reallySet.__doc__N)r7rr@r3r4rrrrr�"test_namedAnySecondAttributeLookup�s��z/LookupsTests.test_namedAnySecondAttributeLookupcCsD|�ttjd�|�ttjd�|�ttjd�|�ttjd�dS)z�
        Exceptions raised by modules which L{namedAny} causes to be imported
        should pass through L{namedAny} to the caller.
        ztwisted.test.reflect_helper_ZDEztwisted.test.reflect_helper_VEztwisted.test.reflect_helper_IEN)�assertRaises�ZeroDivisionErrorrr@�
ValueError�ImportErrorrrrr�test_importExceptionss(����z"LookupsTests.test_importExceptionscCs4|�ttjd�|�ttjd�|�ttjd�dS)z�
        If segments on the end of a fully-qualified Python name represents
        attributes which aren't actually present on the object represented by
        the earlier segments, L{namedAny} should raise an L{AttributeError}.
        ztwisted.nosuchmoduleintheworldz twisted.nosuch.modulein.theworldz0twisted.test.test_reflect.Summer.nosuchattributeN)rI�AttributeErrorrr@rrrr�test_attributeExceptions!s���z%LookupsTests.test_attributeExceptionscCs�|�tjtjd�}|�t|�d�|�tjtjd�}|�t|�d�|�tjtjd�}|�t|�d�|�tjtjd�}|�t|�d�d	D],}|�tjtj|�}|�t|�d
|f�q�dS)a�
        Passing a name which isn't a fully-qualified Python name to L{namedAny}
        should result in one of the following exceptions:
         - L{InvalidName}: the name is not a dot-separated list of Python
           objects
         - L{ObjectNotFound}: the object doesn't exist
         - L{ModuleNotFound}: the object doesn't exist and there is only one
           component in the name
        Znosuchmoduleintheworldz(No module named 'nosuchmoduleintheworld'z@#$@(#.!@(#!@#z('@#$@(#.!@(#!@#' does not name an objectztcelfer.nohtyp.detsiwtz0'tcelfer.nohtyp.detsiwt' does not name an object�zEmpty module name)z.twistedztwisted.ztwisted..pythonzOname must be a string giving a '.'-separated list of Python identifiers, not %rN)rIrZModuleNotFoundr@r�strZObjectNotFoundZInvalidName)r�errZinvalidNamerrr�test_invalidNames6s:
�������zLookupsTests.test_invalidNamescCs.dD]$}t�}tj||d�}|�||�qdS)zk
        When module import fails with ImportError it returns the specified
        default value.
        )Znosuchmtopodule�no.such.module��defaultN)r1r�
requireModuler7)r�namerVr2rrr�test_requireModuleImportError[sz*LookupsTests.test_requireModuleImportErrorcCst�d�}|�|�dS)zI
        When module import fails it returns L{None} by default.
        rTN)rrWZassertIsNone)rr2rrr�test_requireModuleDefaultNonehs
z*LookupsTests.test_requireModuleDefaultNonecCs,ddlm}t�}|�tjd|d�|�dS)ze
        When module import succeed it returns the module and not the default
        value.
        rr9r;rUN)r<r:r1r7rrW)rr:rVrrr�!test_requireModuleRequestedImportqs�z.LookupsTests.test_requireModuleRequestedImportN)rrrrr8r>rDrErFrGrHrMrOrSrYrZr[rrrrr5�s	
			
%
	r5c@s$eZdZdZdZdd�Zdd�ZdS)�	BreakableFcCs|jrtd��ndSdS)Nzstr!z<Breakable>)�breakStr�RuntimeErrorrrrr�__str__�s
zBreakable.__str__cCs|jrtd��ndSdS)Nzrepr!zBreakable())�	breakReprr^rrrr�__repr__�s
zBreakable.__repr__N)rrrr`r]r_rarrrrr\�sr\c@s eZdZdZdd�Zee�ZdS)�
BrokenTypeFcCs|jrtd��dS)Nzno namerb)�	breakNamer^rrrr�get___name__�szBrokenType.get___name__N)rrrrcrd�propertyrrrrrb�srb�BTBaseT)r`r]c@seZdZedd��ZdS)�NoClassAttrcCs|jSr.)Z	not_class)rrrr�<lambda>��zNoClassAttr.<lambda>N)rrrre�	__class__rrrrrg�srgc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�
SafeReprTestsz2
    Tests for L{reflect.safe_repr} function.
    cCs4dddgdf}|�tttj|��ttt|���dS)zg
        L{reflect.safe_repr} produces the same output as C{repr} on a working
        object.
        r0���aN)r�list�mapr�	safe_repr�repr)rZxsrrr�test_workingRepr�szSafeReprTests.test_workingReprcCsJt�}d|_t�|�}|�d|�|�tj�t�d|�|�d|�dS)z�
        L{reflect.safe_repr} returns a string with class name, address, and
        traceback when the repr call failed.
        TzBreakable instance at 0xr�RuntimeError: repr!N)	r\r`rrq�assertIn�os�path�splitext�__file__�r�bZbReprrrr�test_brokenRepr�s
zSafeReprTests.test_brokenReprcCs&t�}d|_|�t�|�t|��dS)zT
        L{reflect.safe_repr} isn't affected by a broken C{__str__} method.
        TN)r\r]rrrqrr�rr{rrr�test_brokenStr�szSafeReprTests.test_brokenStrcCs*Gdd�dt�}t�|�t�|��dS)Nc@seZdZdZdS)z-SafeReprTests.test_brokenClassRepr.<locals>.XTN�rrrr`rrrr�X�sr��rfrrq�rr�rrr�test_brokenClassRepr�s
z"SafeReprTests.test_brokenClassReprcCsBGdd�dt�}t�|�}dt|�f}|�||�d�d�dS)z�
        C{id} is used to print the ID of the object in case of an error.

        L{safe_repr} includes a traceback after a newline, so we only check
        against the first line of the repr.
        c@seZdZdZdS)z2SafeReprTests.test_brokenReprIncludesID.<locals>.XTNrrrrrr��sr�z-<BrokenType instance at 0x%x with repr error:�
rN)rfrrq�idr�split)rr��xReprZ
xReprExpectedrrr�test_brokenReprIncludesID�s
�z'SafeReprTests.test_brokenReprIncludesIDcCs*Gdd�dt�}t�|�t�|��dS)Nc@seZdZdZdS)z,SafeReprTests.test_brokenClassStr.<locals>.XTN�rrrr]rrrrr��sr�r�r�rrr�test_brokenClassStr�s
z!SafeReprTests.test_brokenClassStrcCsJt�}d|_t�|�}|�d|�|�tj�t�d|�|�d|�dS)z�
        If an object raises an exception when accessing its C{__class__}
        attribute, L{reflect.safe_repr} uses C{type} to retrieve the class
        object.
        T�NoClassAttr instance at 0xrrtN)	rgr`rrqrurvrwrxryrzrrr�test_brokenClassAttribute�s
z'SafeReprTests.test_brokenClassAttributecCsPGdd�dt�}t�|��}|�d|�|�tj�t�d|�|�d|�dS)z�
        If a class raises an exception when accessing its C{__name__} attribute
        B{and} when calling its C{__str__} implementation, L{reflect.safe_repr}
        returns 'BROKEN CLASS' instead of the class name.
        c@seZdZdZdS)z6SafeReprTests.test_brokenClassNameAttribute.<locals>.XTN�rrrrcrrrrr�sr��<BROKEN CLASS AT 0xrrtN)rfrrqrurvrwrxry)rr�r�rrr�test_brokenClassNameAttribute�s
z+SafeReprTests.test_brokenClassNameAttributeN)rrrrrsr|r~r�r�r�r�r�rrrrrk�s		rkc@szeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Ze	r@de_
nd
e_
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�SafeStrTestsz1
    Tests for L{reflect.safe_str} function.
    cCs$dddg}|�t�|�t|��dS)Nr0rlrm)rr�safe_strrQ�rrrrr�test_workingStrs
zSafeStrTests.test_workingStrcCst�}d|_t�|�dS�NT)r\r]rr�r}rrrr~szSafeStrTests.test_brokenStrcCsd}|�t�|�d�dS)zh
        L{safe_str} for C{str} with ascii-only data should return the
        value unchanged.
        �aN�rrr�r�rrr�test_workingAsciiszSafeStrTests.test_workingAsciicCsd}|�t�|�|�dS)zk
        L{safe_str} for C{str} with utf-8 encoded data should return the
        value unchanged.
        �tüstNr�r�rrr�test_workingUtf8_2$szSafeStrTests.test_workingUtf8_2cCs d}|�t�|�|�d��dS)zw
        L{safe_str} for C{bytes} with utf-8 encoded data should return
        the value decoded into C{str}.
        r��utf-8N)rrr��decoder�rrr�test_workingUtf8_3-szSafeStrTests.test_workingUtf8_3z)Skip Python 2 specific test for utf-8 strz+Skip Python 3 specific test for utf-8 bytescCs"d}t�|�}|�|t|��dS)z=
        Use str() for non-utf8 bytes: "b'non-utf8'"
        ��N)rr�rrQ)rr�xStrrrr�test_brokenUtf8@s
zSafeStrTests.test_brokenUtf8cCst�}d|_t�|�dSr�)r\r`rr�r}rrrr|IszSafeStrTests.test_brokenReprcCs*Gdd�dt�}t�|�t�|��dS)Nc@seZdZdZdS)z+SafeStrTests.test_brokenClassStr.<locals>.XTNr�rrrrr�Psr��rfrr�r�rrrr�Os
z SafeStrTests.test_brokenClassStrcCs*Gdd�dt�}t�|�t�|��dS)Nc@seZdZdZdS)z,SafeStrTests.test_brokenClassRepr.<locals>.XTNrrrrrr�Wsr�r�r�rrrr�Vs
z!SafeStrTests.test_brokenClassReprcCsJt�}d|_t�|�}|�d|�|�tj�t�d|�|�d|�dS)z�
        If an object raises an exception when accessing its C{__class__}
        attribute, L{reflect.safe_str} uses C{type} to retrieve the class
        object.
        Tr�r�RuntimeError: str!N)	rgr]rr�rurvrwrxry)rr{ZbStrrrrr�]s
z&SafeStrTests.test_brokenClassAttributecCsPGdd�dt�}t�|��}|�d|�|�tj�t�d|�|�d|�dS)z�
        If a class raises an exception when accessing its C{__name__} attribute
        B{and} when calling its C{__str__} implementation, L{reflect.safe_str}
        returns 'BROKEN CLASS' instead of the class name.
        c@seZdZdZdS)z5SafeStrTests.test_brokenClassNameAttribute.<locals>.XTNr�rrrrr�qsr�r�rr�N)rfrr�rurvrwrxry)rr�r�rrrr�ks
z*SafeStrTests.test_brokenClassNameAttributeN)rrrrr�r~r�r�r�r�skipr�r|r�r�r�r�rrrrr�s 		�	r�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�FilenameToModuleTestsz1
    Test L{filenameToModuleName} detection.
    c	Cs�tj�|��dd�|_t�|j�ttj�|jd�d��}|�d�W5QRXttj�tj�|j�d�d��}|�d�W5QRXdS)NZfakepackageZtestz__init__.py�wrP)rvrw�joinZmktemp�makedirs�open�write�dirname)r�frrr�setUps�zFilenameToModuleTests.setUpcCs<t�|j�}|�|d�t�|jtjj�}|�|d�dS)zk
        L{filenameToModuleName} returns the correct module (a package) given a
        directory.
        zfakepackage.testN)r�filenameToModuleNamerwrrv�sep�r�modulerrr�test_directory�sz$FilenameToModuleTests.test_directorycCs&t�tj�|jd��}|�|d�dS)zh
        L{filenameToModuleName} returns the correct module given the path to
        its file.
        ztest_reflect.py�fakepackage.test.test_reflectN)rr�rvrwr�rr�rrr�	test_file�s�zFilenameToModuleTests.test_filecCs,t�tj�|j�d�d��}|�|d�dS)zo
        L{filenameToModuleName} returns the correct module given a C{bytes}
        path to its file.
        r�stest_reflect.pyr�N)rr�rvrwr��encoderr�rrr�
test_bytes�s�z FilenameToModuleTests.test_bytesN)rrrrr�r�r�r�rrrrr�zs


r�c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�FullyQualifiedNameTestsz)
    Test for L{fullyQualifiedName}.
    cCs|�t|�|�dS)ze
        Helper to check that fully qualified name of C{obj} results to
        C{expected}.
        N)rr
)r�objZexpectedrrr�_checkFullyQualifiedName�sz0FullyQualifiedNameTests._checkFullyQualifiedNamecCs.ddl}|�|d�ddl}|�|jd�dS)zd
        L{fullyQualifiedName} returns the full name of a package and a
        subpackage.
        rNrCr?)rCr�r<rArBrrr�test_package�sz$FullyQualifiedNameTests.test_packagecCsddl}|�|jjd�dS)zV
        L{fullyQualifiedName} returns the name of a module inside a package.
        rNztwisted.python.compat)�twisted.python.compatr�rA�compatrBrrr�test_module�s
�z#FullyQualifiedNameTests.test_modulecCs|�tdtf�dS)zS
        L{fullyQualifiedName} returns the name of a class and its module.
        z%s.FullyQualifiedNameTestsN)r�r�rrrrr�
test_class�s�z"FullyQualifiedNameTests.test_classcCs|�td�dS)zY
        L{fullyQualifiedName} returns the name of a function inside its module.
        z)twisted.python.reflect.fullyQualifiedNameN)r�r
rrrr�
test_function�s�z%FullyQualifiedNameTests.test_functioncCs|�|jdt|jjf�dS)zs
        L{fullyQualifiedName} returns the name of a bound method inside its
        class and its module.
        z%s.%s.test_boundMethodN)r��test_boundMethodrrjrrrrr��s�z(FullyQualifiedNameTests.test_boundMethodcCs |�|jjdt|jjf�dS)zv
        L{fullyQualifiedName} returns the name of an unbound method inside its
        class and its module.
        z%s.%s.test_unboundMethodN)r�rj�test_unboundMethodrrrrrr��s�z*FullyQualifiedNameTests.test_unboundMethodN)rrrrr�r�r�r�r�r�r�rrrrr��s		
r�c@s\eZdZerdZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dS)�ObjectGrepTestsz=twisted.python.reflect.objgrep hasn't been ported to Python 3cCsJt�}d|i}|di}|�dt�||tj��|�dt�||tj��dS)zV
        Test references search through a dictionary, as a key or as a value.
        Nz[None]z{None}�r1rur�objgrep�isSame)r�oZd1Zd2rrr�test_dictionary�s
zObjectGrepTests.test_dictionarycCs*t�}d|g}|�dt�||tj��dS)z8
        Test references search through a list.
        N�[1]r�)rr��Lrrr�	test_listszObjectGrepTests.test_listcCs*t�}|df}|�dt�||tj��dS)z9
        Test references search through a tuple.
        N�[0]r�)rr��Trrr�
test_tuple
szObjectGrepTests.test_tuplecCs<Gdd�d�}t�}|�}||_|�dt�||tj��dS)zE
        Test references search through an object attribute.
        c@seZdZdS)z,ObjectGrepTests.test_instance.<locals>.DummyNr)rrrr�Dummysr�z.oN)r1r�rurr�r�)rr�r��drrr�
test_instances
zObjectGrepTests.test_instancecCs:Gdd�d�}|�}t�|�}|�dt�||tj��dS)zB
        Test references search through a weakref object.
        c@seZdZdS)z+ObjectGrepTests.test_weakref.<locals>.DummyNr)rrrrr�#sr�z()N)�weakref�refrurr�r�)rr�r�Zw1rrr�test_weakrefs
zObjectGrepTests.test_weakrefcCsnGdd�d�}|�}|j}|�dt�||jtj��|�dt�||jjtj��|�dt�||jtj��dS)zK
        Test references search through method special attributes.
        c@seZdZdd�ZdS)z/ObjectGrepTests.test_boundMethod.<locals>.DummycSsdSr.rrrrr�dummy/sz5ObjectGrepTests.test_boundMethod.<locals>.Dummy.dummyN)rrrr�rrrrr�.sr�z	.__self__z.__self__.__class__z	.__func__N)r�rurr��__self__r�rj�__func__)rr�r��mrrrr�*s���z ObjectGrepTests.test_boundMethodc
Cs�Gdd�d�}|�}dddd|di}dd|dg}|i|�f}d	d
|d�}|�}||_|j}t�|�}	|�dt�|	|tj��dS)
zF
        Test references search using complex set of objects.
        c@seZdZdd�ZdS)z.ObjectGrepTests.test_everything.<locals>.DummycSsdSr.rrrrrr@sz5ObjectGrepTests.test_everything.<locals>.Dummy.methodN)rrrrrrrrr�?sr�rZbazNZQuuxZFooshrmZfooZbar)rr0rlz"().__self__.attr[2][0][2]{'Foosh'})�attrrr�r�rurr�r�)
rr�r�ZD1r�r�ZD2�ir�r�rrr�test_everything;s
�zObjectGrepTests.test_everythingc	Cs~g}|g}||g}||g}|�dgtj||tjdd��|�ddgtj||tjdd��|�dddgtj||tjdd��dS)	z6
        Test the depth of references search.
        r�r0)ZmaxDepthz[1][0]rlz	[1][1][0]rmN)rrr�r�)rr�r{�cr�rrr�test_depthLimitPs zObjectGrepTests.test_depthLimitcCs<t�}t�}|�d�|�|�|�dt�||tj��dS)z@
        Test references search through a deque object.
        Nr�)r1r�appendrurr�r�)rr��Drrr�
test_deque^s


zObjectGrepTests.test_dequeN)rrrrr�r�r�r�r�r�r�r�r�r�rrrrr��s		r�c@s0eZdZerdgZnddgZdd�Zdd�ZdS)	�
GetClassTests�type�classZclassobjcCsBGdd�d�}|�}|�t�|�j|j�|�t�|�jd�dS)Nc@seZdZdS)z(GetClassTests.test_old.<locals>.OldClassNr)rrrr�OldClassqsr�)rur�getClassr�
oldClassNamesr)rr��oldrrr�test_oldpszGetClassTests.test_oldcCsBGdd�dt�}|�}|�t�|�jd�|�t�|�jd�dS)Nc@seZdZdS)z(GetClassTests.test_new.<locals>.NewClassNr)rrrr�NewClassxsr�r�)r1rrr�r)rr��newrrr�test_newwszGetClassTests.test_newN)rrrrr�r�r�rrrrr�js
r�),rZ
__future__rrrvr��collectionsrr�rZ
twisted.trialrZtwisted.trial.unittestrZTestCaser<rZtwisted.python.reflectr	r
rrr
r1rrrrr%r'r,r3r5r\r�rbrfrgrkr�r�r�r�r�rrrr�<module>sB
,D��ao0Fz