+
    Dfj_                        R t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHtH	t	H
t
HtHt ^ RIHt  ! R R4      t ! R R	]4      t ! R
 R4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R4      t ! R R]4      t ! R R4      t ! R R]]4      t]! R]3RRRR/4      t ! R  R!]4      t ! R" R#]4      t ! R$ R%]4      t ! R& R']4      t  ! R( R)]4      t! ! R* R+]4      t" ! R, R-]4      t#R# ).z6
Test cases for the L{twisted.python.reflect} module.
N)deque)reflect)accumulateMethodsaddMethodNamesToDictfullyQualifiedNameprefixedMethodNamesprefixedMethods)SynchronousTestCasec                   *   a  ] tR t^t o RtR tRtV tR# )BasezT
A no-op class which can be used to verify the behavior of
method-discovering APIs.
c                    R# )z)
A no-op method which can be discovered.
N selfs   &;/usr/lib/python3/dist-packages/twisted/test/test_reflect.pymethodBase.method           r   N)__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classdictcell____classdict__s   @r   r   r      s     
 r   r   c                       ] tR t^$tRtRtR# )Subz>
A subclass of a class with a method which can be discovered.
r   N)r   r   r   r   r   r   r   r   r   r   r   $   s    r   r   c                   0   a  ] tR t^*t o RtR tR tRtV tR# )Separatez5
A no-op class with methods with differing prefixes.
c                    R# )z:
A no-op method which a matching prefix to be discovered.
Nr   r   s   &r   good_methodSeparate.good_method/   r   r   c                    R# )z?
A no-op method with a mismatched prefix to not be discovered.
Nr   r   s   &r   
bad_methodSeparate.bad_method4   r   r   r   N)	r   r   r   r   r   r#   r&   r   r   r   s   @r   r!   r!   *   s     
 r   r!   c                   6   a  ] tR t^:t o RtR tR tR tRtV t	R# )AccumulateMethodsTestszh
Tests for L{accumulateMethods} which finds methods on a class hierarchy and
adds them to a dictionary.
c                p    \        4       p/ p\        W4       V P                  RVP                  /V4       R# )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.
r   N)r   r   assertEqualr   r   xoutputs   &  r   test_ownClass$AccumulateMethodsTests.test_ownClass@   s1     F!$(AHH-v6r   c                p    \        4       p/ p\        W4       V P                  RVP                  /V4       R# )z
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.
r   N)r   r   r+   r   r,   s   &  r   test_baseClass%AccumulateMethodsTests.test_baseClassK   s1     E!$(AHH-v6r   c                r    \        4       p/ p\        WR4       V P                  RVP                  /V4       R# )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_r   N)r!   r   r+   r#   r,   s   &  r   test_prefix"AccumulateMethodsTests.test_prefixW   s3     J!W-(AMM2F;r   r   N)
r   r   r   r   r   r/   r2   r6   r   r   r   s   @r   r)   r)   :   s     
	7
7	< 	<r   r)   c                   0   a  ] tR t^ct o RtR tR tRtV tR# )PrefixedMethodsTestszf
Tests for L{prefixedMethods} which finds methods on a class hierarchy and
adds them to a dictionary.
c                j    \        4       p\        V4      pV P                  VP                  .V4       R# )zK
L{prefixedMethods} returns a list of the methods discovered on an
object.
N)r   r   r+   r   r,   s   &  r   test_onlyObject$PrefixedMethodsTests.test_onlyObjecti   s+    
 F #!((V,r   c                l    \        4       p\        VR4      pV P                  VP                  .V4       R# )zW
If a prefix is given, L{prefixedMethods} returns only methods named
with that prefix.
r5   N)r!   r   r+   r#   r,   s   &  r   r6    PrefixedMethodsTests.test_prefixr   s-    
 J G,!--&1r   r   N)	r   r   r   r   r   r;   r6   r   r   r   s   @r   r9   r9   c   s     
-2 2r   r9   c                   0   a  ] tR t^|t o RtR tR tRtV tR# )PrefixedMethodNamesTestsz#
Tests for L{prefixedMethodNames}.
c                H    V P                  R.\        \        R4      4       R# )zr
L{prefixedMethodNames} returns a list including methods with the given
prefix defined on the class passed to it.
r   r5   N)r+   r   r!   r   s   &r   test_method$PrefixedMethodNamesTests.test_method   s    
 	(%87%KLr   c                ^     ! R R\         4      pV P                  R.\        VR4      4       R# )z
L{prefixedMethodNames} returns a list included methods with the given
prefix defined on base classes of the class passed to it.
c                       ] tR t^tRtR# )<PrefixedMethodNamesTests.test_inheritedMethod.<locals>.Childr   Nr   r   r   r   r   r   r   r   ChildrF          r   rH   r   r5   N)r!   r+   r   )r   rH   s   & r   test_inheritedMethod-PrefixedMethodNamesTests.test_inheritedMethod   s*    	H 	 	(%8%HIr   r   N)	r   r   r   r   r   rB   rJ   r   r   r   s   @r   r@   r@   |   s     M	J 	Jr   r@   c                   *   a  ] tR t^t o RtR tRtV tR# )AddMethodNamesToDictTestsz$
Tests for L{addMethodNamesToDict}.
c                     ! R R4      p ! R R\         V4      p/ p\        W#RV4       V P                  R^/V4       R# )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                       ] tR t^tRtR# );AddMethodNamesToDictTests.test_baseClass.<locals>.Alternater   NrG   r   r   r   	AlternaterP      rI   r   rQ   c                   &   a  ] tR t^t o R tRtV tR# )7AddMethodNamesToDictTests.test_baseClass.<locals>.Childc                    R # Nr   r   s   &r   good_alternateFAddMethodNamesToDictTests.test_baseClass.<locals>.Child.good_alternate       r   r   N)r   r   r   r   rV   r   r   r   s   @r   rH   rS            r   rH   r5   	alternateN)r!   r   r+   )r   rQ   rH   results   &   r   r2   (AddMethodNamesToDictTests.test_baseClass   sB    	 		Hi 	 UGY?+q)62r   r   N)r   r   r   r   r   r2   r   r   r   s   @r   rM   rM      s     3 3r   rM   c                   *   a  ] tR t^t o RtR tRtV tR# )Summerz1
A class we look up as part of the LookupsTests.
c                    R# )z
Do something.
Nr   r   s   &r   	reallySetSummer.reallySet   r   r   r   N)r   r   r   r   r   r`   r   r   r   s   @r   r^   r^      s      r   r^   c                   r   a  ] tR t^t o RtR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tR tRtV tR# )LookupsTestsz;
Tests for L{namedClass}, L{namedModule}, and L{namedAny}.
c                Z    V P                  \        P                  ! R4      \        4       R# )zI
L{namedClass} should return the class object for the name it is passed.
 twisted.test.test_reflect.SummerN)assertIsr   
namedClassr^   r   s   &r   test_namedClassLookup"LookupsTests.test_namedClassLookup   s     	g(()KLfUr   c                ^    ^ RI Hp V P                  \        P                  ! R4      V4       R# )zK
L{namedModule} should return the module object for the name it is
passed.
monkeytwisted.python.monkeyN)twisted.pythonrl   rf   r   namedModuler   rl   s   & r   test_namedModuleLookup#LookupsTests.test_namedModuleLookup   s!    
 	*g))*ABFKr   c                n    ^ RI pV P                  \        P                  ! R4      VP                  4       R# )zI
L{namedAny} should return the package object for the name it is passed.
Ntwisted.python)rn   rf   r   namedAnypythonr   twisteds   & r   test_namedAnyPackageLookup'LookupsTests.test_namedAnyPackageLookup   s%     	g&&'78'..Ir   c                ^    ^ RI Hp V P                  \        P                  ! R4      V4       R# )zH
L{namedAny} should return the module object for the name it is passed.
rk   rm   N)rn   rl   rf   r   ru   rp   s   & r   test_namedAnyModuleLookup&LookupsTests.test_namedAnyModuleLookup   s!     	*g&&'>?Hr   c                Z    V P                  \        P                  ! R4      \        4       R# )zG
L{namedAny} should return the class object for the name it is passed.
re   N)rf   r   ru   r^   r   s   &r   test_namedAnyClassLookup%LookupsTests.test_namedAnyClassLookup   s     	g&&'IJFSr   c                n    V P                  \        P                  ! R4      \        P                  4       R# )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)r+   r   ru   r^   r`   r   s   &r   test_namedAnyAttributeLookup)LookupsTests.test_namedAnyAttributeLookup   s*     	IJ	
r   c                    V P                  \        P                  ! R4      \        P                  P
                  4       R# )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)rf   r   ru   r^   r`   r   r   s   &r   "test_namedAnySecondAttributeLookup/LookupsTests.test_namedAnySecondAttributeLookup   s.     	TU$$	
r   c                .   V P                  \        \        P                  R4       V P                  \        \        P                  R4       V P                  \        \        P                  R4       V P                  \
        \        P                  R4       R# )zu
Exceptions raised by modules which L{namedAny} causes to be imported
should pass through L{namedAny} to the caller.
ztwisted.test.reflect_helper_ZDEztwisted.test.reflect_helper_VEztwisted.test.reflect_helper_IEN)assertRaisesZeroDivisionErrorr   ru   
ValueErrorImportErrorr   s   &r   test_importExceptions"LookupsTests.test_importExceptions   sz    
 	w//1R	
 	w//1R	
 	((*J	

 	))+K	
r   c                    V P                  \        \        P                  R4       V P                  \        \        P                  R4       V P                  \        \        P                  R4       R# )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}.
ztwisted.nosuchmoduleintheworldz twisted.nosuch.modulein.theworldz0twisted.test.test_reflect.Summer.nosuchattributeN)r   AttributeErrorr   ru   r   s   &r   test_attributeExceptions%LookupsTests.test_attributeExceptions  s]     	G,,.N	
 	G,,.P	
 	>	
r   c                   V P                  \        P                  \        P                  R4      pV P	                  \        V4      R4       V P                  \        P                  \        P                  R4      pV P	                  \        V4      R4       V P                  \        P                  \        P                  R4      pV P	                  \        V4      R4       V P                  \        P                  \        P                  R4      pV P	                  \        V4      R4       R FQ  pV P                  \        P                  \        P                  V4      pV P	                  \        V4      R	V: 24       KS  	  R
# )aU  
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
nosuchmoduleintheworldz(No module named 'nosuchmoduleintheworld'z@#$@(#.!@(#!@#z('@#$@(#.!@(#!@#' does not name an objectztcelfer.nohtyp.detsiwtz0'tcelfer.nohtyp.detsiwt' does not name an object zEmpty module namezMname must be a string giving a '.'-separated list of Python identifiers, not N)z.twistedztwisted.ztwisted..python)r   r   ModuleNotFoundru   r+   strObjectNotFoundInvalidName)r   errinvalidNames   &  r   test_invalidNamesLookupsTests.test_invalidNames"  s4    ""G$4$46N
 	S#MN ""G$4$46F
 	S#MN""G$4$46N
 	S#UV 3 3W5E5ErJS#67FK##G$7$79I9I;WCC)47 Gr   c                |    R F5  p\        4       p\        P                  ! WR7      pV P                  W24       K7  	  R# )zS
When module import fails with ImportError it returns the specified
default value.
defaultN)nosuchmtopoduleno.such.module)objectr   requireModulerf   )r   namer   r[   s   &   r   test_requireModuleImportError*LookupsTests.test_requireModuleImportErrorG  s1    
 :DhG**4AFMM&* :r   c                T    \         P                  ! R4      pV P                  V4       R# )z9
When module import fails it returns L{None} by default.
r   N)r   r   assertIsNone)r   r[   s   & r   test_requireModuleDefaultNone*LookupsTests.test_requireModuleDefaultNoneS  s#     &&'78&!r   c                v    ^ RI Hp \        4       pV P                  \        P
                  ! RVR7      V4       R# )zM
When module import succeed it returns the module and not the default
value.
rk   rm   r   N)rn   rl   r   rf   r   r   )r   rl   r   s   &  r   !test_requireModuleRequestedImport.LookupsTests.test_requireModuleRequestedImport[  s.    
 	*(!!"97K	
r   r   N)r   r   r   r   r   rh   rq   ry   r|   r   r   r   r   r   r   r   r   r   r   r   r   s   @r   rc   rc      sV     VLJIT
	

*
*#J
+"
 
r   rc   c                   L   a  ] tR tRt o RtRtV 3R lR ltV 3R lR ltRtV t	R# )		Breakableij  Fc                    < V ^8  d   QhRS[ /#    returnr   )formatr   s   "r   __annotate__Breakable.__annotate__n  s     ! ! !r   c                @    V P                   '       d   \        R 4      hR# )zstr!z<Breakable>)breakStrRuntimeErrorr   s   &r   __str__Breakable.__str__n  s    ===v&& r   c                    < V ^8  d   QhRS[ /# r   r   )r   r   s   "r   r   r   t  s     ! !# !r   c                @    V P                   '       d   \        R 4      hR# )zrepr!zBreakable())	breakReprr   r   s   &r   __repr__Breakable.__repr__t  s    >>>w'' r   r   N)
r   r   r   r   r   r   r   r   r   r   r   s   @r   r   r   j  s#     IH! !! !r   r   c                   4   a  ] tR tRt o Rt]R 4       t RtV tR# )
BrokenTypei{  Fc                @    V P                   '       d   \        R 4      hR# )zno namer   )	breakNamer   r   s   &r   r   BrokenType.__name__~  s    >>>y))r   r   N)r   r   r   r   r   propertyr   r   r   s   @r   r   r   {  s     I r   r   BTBaser   Tr   c                   (    ] tR tRt]! R 4      tRtR# )NoClassAttri  c                    V P                   # rU   )	not_class)r-   s   &r   <lambda>NoClassAttr.<lambda>  s    1;;r   r   N)r   r   r   r   r   	__class__r   r   r   r   r   r     s    ./Ir   r   c                   T   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tRtV tR# )SafeReprTestsi  z*
Tests for L{reflect.safe_repr} function.
c           	         . ROR3pV P                  \        \        \        P                  V4      4      \        \        \
        V4      4      4       R# )zO
L{reflect.safe_repr} produces the same output as C{repr} on a working
object.
   aN   r      )r+   listmapr   	safe_reprrepr)r   xss   & r   test_workingReprSafeReprTests.test_workingRepr  s;    
 c'"3"3R894D";NOr   c                   \        4       pRVn        \        P                  ! V4      pV P	                  RV4       V P	                  \
        P                  P                  \        4      ^ ,          V4       V P	                  RV4       R# )zj
L{reflect.safe_repr} returns a string with class name, address, and
traceback when the repr call failed.
TzBreakable instance at 0xRuntimeError: repr!N)	r   r   r   r   assertInospathsplitext__file__r   bbReprs   &  r   test_brokenReprSafeReprTests.test_brokenRepr  sd    
 K!!!$0%8 	bgg&&x03U;+U3r   c                    \        4       pRVn        V P                  \        P                  ! V4      \        V4      4       R# )zD
L{reflect.safe_repr} isn't affected by a broken C{__str__} method.
TN)r   r   r+   r   r   r   r   r   s   & r   test_brokenStrSafeReprTests.test_brokenStr  s1     K
**1-tAw7r   c                     ! R  R\         4      p\        P                  ! V4       \        P                  ! V! 4       4       R# )c                       ] tR tRtRtRtR# )-SafeReprTests.test_brokenClassRepr.<locals>.Xi  Tr   Nr   r   r   r   r   r   r   r   r   Xr         Ir   r   Nr   r   r   r   r   s   & r   test_brokenClassRepr"SafeReprTests.test_brokenClassRepr  s.    	 	 	!!#r   c                     ! R R\         4      p\        P                  ! V4      pR\        V4      R R2pV P	                  W2P                  R4      ^ ,          4       R# )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                       ] tR tRtRtRtR# )2SafeReprTests.test_brokenReprIncludesID.<locals>.Xi  Tr   Nr   r   r   r   r   r     r   r   r   z<BrokenType instance at 0xr-   z with repr error:
N)r   r   r   idr+   split)r   r   xReprxReprExpecteds   &   r   test_brokenReprIncludesID'SafeReprTests.test_brokenReprIncludesID  sQ    	 	 !!!$4RU1I=NOD(9!(<=r   c                     ! R  R\         4      p\        P                  ! V4       \        P                  ! V! 4       4       R# )c                       ] tR tRtRtRtR# ),SafeReprTests.test_brokenClassStr.<locals>.Xi  Tr   Nr   r   r   r   r   r   r   r   r   r   r        Hr   r   Nr   r   s   & r   test_brokenClassStr!SafeReprTests.test_brokenClassStr  s.    	 	 	!!#r   c                   \        4       pRVn        \        P                  ! V4      pV P	                  RV4       V P	                  \
        P                  P                  \        4      ^ ,          V4       V P	                  RV4       R# )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 0xr   N)	r   r   r   r   r   r   r   r   r   r   s   &  r   test_brokenClassAttribute'SafeReprTests.test_brokenClassAttribute  sb     M!!!$2E:bgg&&x03U;+U3r   c                    ! R R\         4      p\        P                  ! V! 4       4      pV P                  RV4       V P                  \        P
                  P                  \        4      ^ ,          V4       V P                  RV4       R# )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                       ] tR tRtRtRtR# )6SafeReprTests.test_brokenClassNameAttribute.<locals>.Xi  Tr   Nr   r   r   r   r   r   r   r   r   r   r    r   r   r   <BROKEN CLASS AT 0xr   N)r   r   r   r   r   r   r   r   )r   r   r   s   &  r   test_brokenClassNameAttribute+SafeReprTests.test_brokenClassNameAttribute  sb    	 	 !!!#&+U3bgg&&x03U;+U3r   r   N)r   r   r   r   r   r   r   r   r   r   r  r  r  r   r   r   s   @r   r   r     s8     P48>44 4r   r   c                   `   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tRtV tR# )SafeStrTestsi  z)
Tests for L{reflect.safe_str} function.
c                l    . ROpV P                  \        P                  ! V4      \        V4      4       R# )r   Nr   )r+   r   safe_strr   r   r-   s   & r   test_workingStrSafeStrTests.test_workingStr  s&    ))!,c!f5r   c                T    \        4       pR Vn        \        P                  ! V4       R# TN)r   r   r   r  r   s   & r   r   SafeStrTests.test_brokenStr  s    K
r   c                V    RpV P                  \        P                  ! V4      R4       R# )zP
L{safe_str} for C{str} with ascii-only data should return the
value unchanged.
aN)r+   r   r  r  s   & r   test_workingAsciiSafeStrTests.test_workingAscii  s$    
 ))!,c2r   c                t    RpV P                  \        P                  ! V4      VP                  R4      4       R# )z_
L{safe_str} for C{bytes} with utf-8 encoded data should return
the value decoded into C{str}.
s   tüstutf-8N)r+   r   r  decoder  s   & r   test_workingUtf8_3SafeStrTests.test_workingUtf8_3  s-    
 ))!,ahhw.?@r   c                l    Rp\         P                  ! V4      pV P                  V\        V4      4       R# )z-
Use str() for non-utf8 bytes: "b'non-utf8'"
   N)r   r  r+   r   )r   r-   xStrs   &  r   test_brokenUtf8SafeStrTests.test_brokenUtf8  s-     "s1v&r   c                T    \        4       pR Vn        \        P                  ! V4       R# r  )r   r   r   r  r   s   & r   r   SafeStrTests.test_brokenRepr  s    Kr   c                     ! R  R\         4      p\        P                  ! V4       \        P                  ! V! 4       4       R# )c                       ] tR tRtRtRtR# )+SafeStrTests.test_brokenClassStr.<locals>.Xi  Tr   Nr  r   r   r   r   r0    r  r   r   Nr   r   r  r   s   & r   r   SafeStrTests.test_brokenClassStr  s.    	 	 	r   c                     ! R  R\         4      p\        P                  ! V4       \        P                  ! V! 4       4       R# )c                       ] tR tRtRtRtR# ),SafeStrTests.test_brokenClassRepr.<locals>.Xi  Tr   Nr   r   r   r   r   r5    r   r   r   Nr1  r   s   & r   r   !SafeStrTests.test_brokenClassRepr  s.    	 	 	r   c                   \        4       pRVn        \        P                  ! V4      pV P	                  RV4       V P	                  \
        P                  P                  \        4      ^ ,          V4       V P	                  RV4       R# )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
  RuntimeError: str!N)	r   r   r   r  r   r   r   r   r   )r   r   bStrs   &  r   r  &SafeStrTests.test_brokenClassAttribute"  sb     M
"2D9bgg&&x03T:*D1r   c                    ! R R\         4      p\        P                  ! V! 4       4      pV P                  RV4       V P                  \        P
                  P                  \        4      ^ ,          V4       V P                  RV4       R# )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                       ] tR tRtRtRtR# )5SafeStrTests.test_brokenClassNameAttribute.<locals>.Xi6  Tr   Nr  r   r   r   r   r=  6  r   r   r   r  r8  N)r   r   r  r   r   r   r   r   )r   r   r)  s   &  r   r  *SafeStrTests.test_brokenClassNameAttribute/  sb    	 	 $+T2bgg&&x03T:*D1r   r   N)r   r   r   r   r   r  r   r   r%  r*  r   r  r   r  r  r   r   r   s   @r   r  r    sB     6
3A'
22 2r   r  c                   <   a  ] tR tRt o RtR tR tR tR tRt	V t
R# )	FilenameToModuleTestsi?  z)
Test L{filenameToModuleName} detection.
c                   \         P                  P                  V P                  4       R R4      V n        \         P                  ! V P                  4       \        \         P                  P                  V P                  R4      R4      ;_uu_ 4       pVP                  R4       RRR4       \        \         P                  P                  \         P                  P                  V P                  4      R4      R4      ;_uu_ 4       pVP                  R4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)fakepackagetestz__init__.pywr   N)r   r   joinmktempmakedirsopenwritedirname)r   fs   & r   setUpFilenameToModuleTests.setUpD  s    GGLLvF	
DII"'',,tyy-8#>>!GGBK ?"'',,rwwtyy9=I3OOSTGGBK PO ?>OOOs   D D3 D0	3E	c                   \         P                  ! V P                  4      pV P                  VR4       \         P                  ! V P                  \        P                  P
                  ,           4      pV P                  VR4       R# )zS
L{filenameToModuleName} returns the correct module (a package) given a
directory.
zfakepackage.testN)r   filenameToModuleNamer   r+   r   sepr   modules   & r   test_directory$FilenameToModuleTests.test_directoryL  s[    
 --dii8!34--dii"''++.EF!34r   c                    \         P                  ! \        P                  P	                  V P                  R4      4      pV P                  VR4       R# )zP
L{filenameToModuleName} returns the correct module given the path to
its file.
ztest_reflect.pyfakepackage.test.test_reflectN)r   rO  r   r   rE  r+   rQ  s   & r   	test_fileFilenameToModuleTests.test_fileV  s>    
 --GGLL$56
 	!@Ar   c                    \         P                  ! \        P                  P	                  V P                  P                  R4      R4      4      pV P                  VR4       R# )zW
L{filenameToModuleName} returns the correct module given a C{bytes}
path to its file.
r#  s   test_reflect.pyrV  N)r   rO  r   r   rE  encoder+   rQ  s   & r   
test_bytes FilenameToModuleTests.test_bytes`  sI    
 --GGLL))'24FG
 	!@Ar   )r   N)r   r   r   r   r   rL  rS  rW  r[  r   r   r   s   @r   r@  r@  ?  s&     5B	B 	Br   r@  c                   N   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
tV tR# )FullyQualifiedNameTestsil  z!
Test for L{fullyQualifiedName}.
c                <    V P                  \        V4      V4       R# )zM
Helper to check that fully qualified name of C{obj} results to
C{expected}.
N)r+   r   )r   objexpecteds   &&&r   _checkFullyQualifiedName0FullyQualifiedNameTests._checkFullyQualifiedNameq  s    
 	+C0(;r   c                r    ^ RI pV P                  VR4       ^ RIpV P                  VP                  R4       R# )zL
L{fullyQualifiedName} returns the full name of a package and a
subpackage.
Nrx   rt   )rx   rb  rn   rv   rw   s   & r   test_package$FullyQualifiedNameTests.test_packagex  s/    
 	%%gy9%%gnn6FGr   c                Z    ^ RI pV P                  VP                  P                  R4       R# )zF
L{fullyQualifiedName} returns the name of a module inside a package.
Nztwisted.python.compat)twisted.python.compatrb  rv   compatrw   s   & r   test_module#FullyQualifiedNameTests.test_module  s"     	%%%gnn&;&;=TUr   c                @    V P                  \        \         R24       R# )zC
L{fullyQualifiedName} returns the name of a class and its module.
z.FullyQualifiedNameTestsN)rb  r^  r   r   s   &r   
test_class"FullyQualifiedNameTests.test_class  s     	%%#z1I%J	
r   c                2    V P                  \        R4       R# )zI
L{fullyQualifiedName} returns the name of a function inside its module.
z)twisted.python.reflect.fullyQualifiedNameN)rb  r   r   s   &r   test_function%FullyQualifiedNameTests.test_function  s     	%% K	
r   c                z    V P                  V P                  \         RV P                  P                   R24       R# )z[
L{fullyQualifiedName} returns the name of a bound method inside its
class and its module.
.z.test_boundMethodN)rb  test_boundMethodr   r   r   s   &r   rt  (FullyQualifiedNameTests.test_boundMethod  s7    
 	%%!!j$..1122CD	
r   c                    V P                  V P                  P                  \         RV P                  P                   R24       R# )z^
L{fullyQualifiedName} returns the name of an unbound method inside its
class and its module.
rs  z.test_unboundMethodN)rb  r   test_unboundMethodr   r   s   &r   rw  *FullyQualifiedNameTests.test_unboundMethod  s;    
 	%%NN--j$..1122EF	
r   r   N)r   r   r   r   r   rb  re  rj  rm  rp  rt  rw  r   r   r   s   @r   r^  r^  l  s4     <
HV



 
r   r^  c                   V   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tRtV tR# )ObjectGrepTestsi  c                    \        4       pRV/pVR/pV P                  R\        P                  ! W!\        P                  4      4       V P                  R\        P                  ! W1\        P                  4      4       R# )zF
Test references search through a dictionary, as a key or as a value.
Nz[None]z{None}r   r   r   objgrepisSame)r   od1d2s   &   r   test_dictionaryObjectGrepTests.test_dictionary  sW     HAYYhw~~ FGhw~~ FGr   c                    \        4       pRV.pV P                  R\        P                  ! W!\        P                  4      4       R# )z(
Test references search through a list.
N[1]r|  )r   r  Ls   &  r   	test_listObjectGrepTests.test_list  s1     H1IeW__Q7>>BCr   c                    \        4       pVR3pV P                  R\        P                  ! W!\        P                  4      4       R# )z)
Test references search through a tuple.
N[0]r|  )r   r  Ts   &  r   
test_tupleObjectGrepTests.test_tuple  s1     HIeW__Q7>>BCr   c                     ! R R4      p\        4       pV! 4       pW#n        V P                  R\        P                  ! W2\        P
                  4      4       R# )z5
Test references search through an object attribute.
c                       ] tR tRtRtR# ),ObjectGrepTests.test_instance.<locals>.Dummyi  r   NrG   r   r   r   Dummyr    rI   r   r  z.oN)r   r  r   r   r}  r~  )r   r  r  ds   &   r   test_instanceObjectGrepTests.test_instance  s>    
	 	 HGdGOOA'..ABr   c                     ! R R4      pV! 4       p\         P                  ! V4      pV P                  R\        P                  ! W2\        P
                  4      4       R# )z2
Test references search through a weakref object.
c                       ] tR tRtRtR# )+ObjectGrepTests.test_weakref.<locals>.Dummyi  r   NrG   r   r   r   r  r    rI   r   r  z()N)weakrefrefr   r   r}  r~  )r   r  r  w1s   &   r   test_weakrefObjectGrepTests.test_weakref  s?    
	 	 G[[^dGOOB7>>BCr   c                    ! R R4      pV! 4       pVP                   pV P                  R\        P                  ! W3P                  \        P
                  4      4       V P                  R\        P                  ! W3P                  P                  \        P
                  4      4       V P                  R\        P                  ! W3P                  \        P
                  4      4       R# )z;
Test references search through method special attributes.
c                   &   a  ] tR tRt o R tRtV tR# )/ObjectGrepTests.test_boundMethod.<locals>.Dummyi  c                    R # rU   r   r   s   &r   dummy5ObjectGrepTests.test_boundMethod.<locals>.Dummy.dummy  rX   r   r   N)r   r   r   r   r  r   r   r   s   @r   r  r    rY   r   r  z	.__self__z.__self__.__class__z	.__func__N)r  r   r   r}  __self__r~  r   __func__)r   r  r  ms   &   r   rt   ObjectGrepTests.test_boundMethod  s    
	 	 GGGk7??1jj'..#QR!OOAzz33W^^D	
 	k7??1jj'..#QRr   c                0    ! R R4      pV! 4       pR
RRRVR/pRR
V^.pV/ V! 4       3p^ R^R^V/pV! 4       pWgn         VP                  p\        P                  ! V4      p	V P	                  R	\
        P                  ! W\
        P                  4      4       R# )z6
Test references search using complex set of objects.
c                   &   a  ] tR tRt o R tRtV tR# ).ObjectGrepTests.test_everything.<locals>.Dummyi  c                    R # rU   r   r   s   &r   r   5ObjectGrepTests.test_everything.<locals>.Dummy.method  rX   r   r   N)r   r   r   r   r   r   r   r   s   @r   r  r    rY   r   r  bazNQuuxFooshfoobarz"().__self__.attr[2][0][2]{'Foosh'}r   )attrr   r  r  r   r   r}  r~  )
r   r  r  D1r  r  D2ir  rD  s
   &         r   test_everythingObjectGrepTests.test_everything  s    
	 	 G%vq'22r1EG5!Q'GHHKKN0'//!2W	
r   c           
     p   . pV.pW.pW.pV P                  R.\        P                  ! WA\        P                  ^R7      4       V P                  RR.\        P                  ! WA\        P                  ^R7      4       V P                  . RO\        P                  ! WA\        P                  ^R7      4       R# )z&
Test the depth of references search.
r  )maxDepth[1][0]N)r  r  z	[1][1][0])r+   r   r}  r~  )r   r  r   cr  s   &    r   test_depthLimitObjectGrepTests.test_depthLimit  s     CFF%'//!QR"STHwqW^^aP	
 	*OOA'..1=	
r   c                    \        4       p\        4       pVP                  R4       VP                  V4       V P                  R\        P
                  ! W!\        P                  4      4       R# )z0
Test references search through a deque object.
Nr  )r   r   appendr   r   r}  r~  )r   r  Ds   &  r   
test_dequeObjectGrepTests.test_deque&  sE     HG		eW__Q7>>BCr   r   N)r   r   r   r   r  r  r  r  r  rt  r  r  r  r   r   r   s   @r   rz  rz    s?     	HDDCDS&
.
$	D 	Dr   rz  c                   &   a  ] tR tRt o R tRtV tR# )GetClassTestsi2  c                     ! R  R4      pV! 4       pV P                  \        P                  ! V4      P                  R4       V P                  \        P                  ! V4      P                  R4       R# )c                       ] tR tRtRtR# )(GetClassTests.test_new.<locals>.NewClassi4  r   NrG   r   r   r   NewClassr  4  rI   r   r  typeN)r+   r   getClassr   )r   r  news   &  r   test_newGetClassTests.test_new3  sW    	 	 j))(3<<fE))#.77Dr   r   N)r   r   r   r   r  r   r   r   s   @r   r  r  2  s     E Er   r  )$r   r   r  collectionsr   rn   r   twisted.python.reflectr   r   r   r   r   twisted.trial.unittestr	   TestCaser   r   r!   r)   r9   r@   rM   r^   rc   r   r  r   r   r   r   r  r@  r^  rz  r  r   r   r   <module>r     s.  
 
   "  C	 	$   &<X &<R28 22Jx J03 3. q
8 q
h! !"D  
Hyl[$
D,Q	R0) 0Z4H Z4zS28 S2l*BH *BZB
h B
J~Dh ~DBEH Er   