+
    Dfj                     `    R t ^ RIt^ RIHt ^ RIHt  ! R R4      tR tR t ! R R	]4      t	R# )
zt
Tests for miscellaneous behaviors of the top-level L{twisted} package (ie, for
the code in C{twisted/__init__.py}.
N)
ModuleType)TestCasec                   <   a  ] tR t^t o RtR tR tR tR tRt	V t
R# )SetAsideModulez
L{SetAsideModule} is a context manager for temporarily removing a module
from C{sys.modules}.

@ivar name: The name of the module to remove.
c                    Wn         R # N)name)selfr   s   &&;/usr/lib/python3/dist-packages/twisted/test/test_twisted.py__init__SetAsideModule.__init__   s    	    c                .   \        \        P                  P                  4       4       UUu/ uFA  w  r#W P                  8X  g+   VP                  V P                  R,           4      '       g   K?  W#bKC  	  pppV F  p\        P                  V K  	  V# u uppi )z
Find the given module and all of its hierarchically inferior modules in
C{sys.modules}, remove them from it, and return whatever was found.
.)listsysmodulesitemsr   
startswith)r	   r   
moduleNamemoduler   s   &&   r
   	_unimportSetAsideModule._unimport   s     )-S[[->->-@(A
(A$ii':+@+@S+Q J(A 	 

 DD! 
s   <B,Bc                F    V P                  V P                  4      V n        R # r   )r   r   r   )r	   s   &r
   	__enter__SetAsideModule.__enter__+   s    ~~dii0r   c                    V P                  V P                  4       \        P                  P	                  V P                  4       R # r   )r   r   r   r   update)r	   excTypeexcValue	tracebacks   &&&&r
   __exit__SetAsideModule.__exit__.   s(    tyy!4<<(r   )r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   r   r!   __static_attributes____classdictcell____classdict__s   @r
   r   r      s#     1) )r   r   c                `    / p\        RW4       \        P                  P                  V4       R# )a  
Take a mapping defining a package and turn it into real C{ModuleType}
instances in C{sys.modules}.

Consider these example::

    a = {"foo": "bar"}
    b = {"twisted": {"__version__": "42.6"}}
    c = {"twisted": {"plugin": {"getPlugins": stub}}}

C{_install(a)} will place an item into C{sys.modules} with C{"foo"} as the
key and C{"bar" as the value.

C{_install(b)} will place an item into C{sys.modules} with C{"twisted"} as
the key.  The value will be a new module object.  The module will have a
C{"__version__"} attribute with C{"42.6"} as the value.

C{_install(c)} will place an item into C{sys.modules} with C{"twisted"} as
the key.  The value will be a new module object with a C{"plugin"}
attribute.  An item will also be placed into C{sys.modules} with the key
C{"twisted.plugin"} which refers to that module object.  That module will
have an attribute C{"getPlugins"} with a value of C{stub}.

@param modules: A mapping from names to definitions of modules.  The names
    are native strings like C{"twisted"} or C{"unittest"}.  Values may be
    arbitrary objects.  Any value which is not a dictionary will be added to
    C{sys.modules} unmodified.  Any dictionary value indicates the value is
    a new module and its items define the attributes of that module.  The
    definition of this structure is recursive, so a value in the dictionary
    may be a dictionary to trigger another level of processing.

@return: L{None}
N)_makePackagesr   r   r   )r   results   & r
   _installr/   3   s&    D F$(KKvr   c                   / p\        VP                  4       4       F  w  rEV fS   \        V\        4      '       d7   \	        V4      pVP
                  P                  \        WeV4      4       WbV&   KU  WRV&   K[  \        V\        4      '       dk   \	        V P                  R,           V,           4      pVP
                  P                  \        WeV4      4       WbV P                  R,           V,           &   WcV&   K  WSV&   K  	  V# )a  
Construct module objects (for either modules or packages).

@param parent: L{None} or a module object which is the Python package
    containing all of the modules being created by this function call.  Its
    name will be prepended to the name of all created modules.

@param attributes: A mapping giving the attributes of the particular module
    object this call is creating.

@param result: A mapping which is populated with all created module names.
    This is suitable for use in updating C{sys.modules}.

@return: A mapping of all of the attributes created by this call.  This is
    suitable for populating the dictionary of C{parent}.

@see: L{_install}.
r   )	r   r   
isinstancedictr   __dict__r   r-   r#   )parent
attributesr.   attrsr   valuer   s   &&&    r
   r-   r-   Z   s    & EJ,,./>%&&#D)&&}VF'KL%t$t%&&#FOOc$9D$@A&&}VF'KL7=v,t34$d#d 0  Lr   c                   6   a  ] tR t^t o RtR tR tR tRtV t	R# )MakePackagesTestsz\
Tests for L{_makePackages}, a helper for populating C{sys.modules} with
fictional modules.
c                p    / p\        R\        RR7      V4       V P                  V\        RR7      4       R# )zy
A non-C{dict} value in the attributes dictionary passed to L{_makePackages}
is preserved unchanged in the return value.
Nreactor)r;   )r-   r2   assertEqualr	   r   s   & r
   test_nonModule MakePackagesTests.test_nonModule   s/    
 dD3W=$y"9:r   c           	     >   / p\        R\        \        RR7      R7      V4       V P                  V\        4       V P                  VR,          \        4       V P	                  RVR,          P
                  4       V P	                  RVR,          P                  4       R# )z
A C{dict} value in the attributes dictionary passed to L{_makePackages}
is turned into a L{ModuleType} instance with attributes populated from
the items of that C{dict} value.
N123versiontwistedrE   )r-   r2   assertIsInstancer   r<   r#   rC   r=   s   & r
   test_moduleWithAttribute*MakePackagesTests.test_moduleWithAttribute   sz     dDe)<=wGgt,gi0*=GI$6$?$?@	 2 : :;r   c                   / p\        R\        \        \        RR7      R7      R7      V4       V P                  V\        4       V P                  VR,          \        4       V P	                  RVR,          P
                  4       V P                  VR,          P                  \        4       V P	                  RVR,          P                  P
                  4       V P	                  RVR,          P                  P                  4       R# )z
Processing of the attributes dictionary is recursive, so a C{dict} value
it contains may itself contain a C{dict} value to the same effect.
N321rB   )webrD   rE   ztwisted.web)r-   r2   rF   r   r<   r#   rK   rC   r=   s   & r
   test_packageWithModule(MakePackagesTests.test_packageWithModule   s    
 dD$u2E)FGQgt,gi0*=GI$6$?$?@gi044jA	(:(>(>(G(GH	 2 6 6 > >?r    N)
r#   r$   r%   r&   r'   r>   rG   rL   r(   r)   r*   s   @r
   r9   r9      s      
;<@ @r   r9   )
r'   r   typesr   twisted.trial.unittestr   r   r/   r-   r9   rN   r   r
   <module>rQ      s:      +
) )B$N$N(@ (@r   