§
    Ètºfƒ  ã                   ól   — d Z ddlZddlmZ ddlmZ  G d„ d¦  «        Zd„ Zd„ Z G d	„ d
e¦  «        Z	dS )zt
Tests for miscellaneous behaviors of the top-level L{twisted} package (ie, for
the code in C{twisted/__init__.py}.
é    N)Ú
ModuleType)ÚTestCasec                   ó*   — e Zd ZdZd„ Zd„ Zd„ Zd„ ZdS )Ú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                 ó   — || _         d S ©N)Úname)Úselfr	   s     úX/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/test/test_twisted.pyÚ__init__zSetAsideModule.__init__   s   € ØˆŒ	ˆ	ˆ	ó    c                 óš   ‡ — ˆ fd„t          t          j                             ¦   «         ¦  «        D ¦   «         }|D ]}t          j        |= Œ|S )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.
        c                 ól   •— i | ]0\  }}|‰j         k    s|                     ‰j         d z   ¦  «        ¯-||“Œ1S )ú.)r	   Ú
startswith)Ú.0Ú
moduleNameÚmoduler
   s      €r   ú
<dictcomp>z,SetAsideModule._unimport.<locals>.<dictcomp>"   sO   ø€ ð 
ð 
ð 
á$�˜VØ˜dœiÒ'Ð'¨:×+@Ò+@ÀÄÈSÁÑ+QÔ+QÐ'ð ˜à'Ð'Ð'r   )ÚlistÚsysÚmodulesÚitems)r
   r	   r   s   `  r   Ú	_unimportzSetAsideModule._unimport   sd   ø€ ð

ð 
ð 
ð 
å(,­S¬[×->Ò->Ñ-@Ô-@Ñ(AÔ(Að
ñ 
ô 
ˆð
 ð 	"ð 	"ˆDÝ”˜DÐ!Ð!Øˆr   c                 óD   — |                       | j        ¦  «        | _        d S r   )r   r	   r   )r
   s    r   Ú	__enter__zSetAsideModule.__enter__+   s   € Ø—~’~ d¤iÑ0Ô0ˆŒˆˆr   c                 ó‚   — |                       | j        ¦  «         t          j                             | j        ¦  «         d S r   )r   r	   r   r   Úupdate)r
   ÚexcTypeÚexcValueÚ	tracebacks       r   Ú__exit__zSetAsideModule.__exit__.   s4   € Ø�Š�t”yÑ!Ô!Ð!ÝŒ×Ò˜4œ<Ñ(Ô(Ð(Ð(Ð(r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r"   © r   r   r   r      sZ   € € € € € ðð ðð ð ðð ð ð1ð 1ð 1ð)ð )ð )ð )ð )r   r   c                 ój   — i }t          d| |¦  «         t          j                             |¦  «         dS )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   s8   € ðD €FÝ�$˜ Ñ(Ô(Ð(Ý„K×Ò�vÑÔÐÐÐr   c                 óô  — i }t          |                     ¦   «         ¦  «        D ]Ó\  }}| €Yt          |t          ¦  «        r>t	          |¦  «        }|j                             t          |||¦  «        ¦  «         |||<   ŒZ|||<   Œ`t          |t          ¦  «        rYt	          | j        dz   |z   ¦  «        }|j                             t          |||¦  «        ¦  «         ||| j        dz   |z   <   |||<   ŒÎ|||<   ŒÔ|S )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}.
    Nr   )	r   r   Ú
isinstanceÚdictr   Ú__dict__r   r)   r#   )ÚparentÚ
attributesr*   Úattrsr	   Úvaluer   s          r   r)   r)   Z   s
  € ð& €EÝ˜J×,Ò,Ñ.Ô.Ñ/Ô/ð $ð $‰ˆˆeØˆ>Ý˜%¥Ñ&Ô&ð %Ý# DÑ)Ô)�Ø”×&Ò&¥}°V¸UÀFÑ'KÔ'KÑLÔLÐLØ%��t‘�à$��t‘�å˜%¥Ñ&Ô&ð $Ý# F¤O°cÑ$9¸DÑ$@ÑAÔA�Ø”×&Ò&¥}°V¸UÀFÑ'KÔ'KÑLÔLÐLØ7=��v”¨Ñ,¨tÑ3Ñ4Ø$��d‘�à#��d‘�Ø€Lr   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚMakePackagesTestszh
    Tests for L{_makePackages}, a helper for populating C{sys.modules} with
    fictional modules.
    c                 ó�   — i }t          dt          d¬¦  «        |¦  «         |                      |t          d¬¦  «        ¦  «         dS )z‘
        A non-C{dict} value in the attributes dictionary passed to L{_makePackages}
        is preserved unchanged in the return value.
        NÚreactor)r7   )r)   r.   ÚassertEqual©r
   r   s     r   Útest_nonModulez MakePackagesTests.test_nonModule‡   sM   € ð
 ˆÝ�d�D¨Ð3Ñ3Ô3°WÑ=Ô=Ð=Ø×Ò˜¥$¨yÐ"9Ñ"9Ô"9Ñ:Ô:Ð:Ð:Ð:r   c                 ó`  — i }t          dt          t          d¬¦  «        ¬¦  «        |¦  «         |                      |t          ¦  «         |                      |d         t          ¦  «         |                      d|d         j        ¦  «         |                      d|d         j        ¦  «         dS )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©Útwistedr@   )r)   r.   ÚassertIsInstancer   r8   r#   r>   r9   s     r   Útest_moduleWithAttributez*MakePackagesTests.test_moduleWithAttribute�   s¤   € ð ˆÝ�d�D­°eÐ)<Ñ)<Ô)<Ð=Ñ=Ô=¸wÑGÔGÐGØ×Ò˜g¥tÑ,Ô,Ð,Ø×Ò˜g iÔ0µ*Ñ=Ô=Ð=Ø×Ò˜ G¨IÔ$6Ô$?Ñ@Ô@Ð@Ø×Ò˜ ¨	Ô 2Ô :Ñ;Ô;Ð;Ð;Ð;r   c           
      ó  — i }t          dt          t          t          d¬¦  «        ¬¦  «        ¬¦  «        |¦  «         |                      |t          ¦  «         |                      |d         t          ¦  «         |                      d|d         j        ¦  «         |                      |d         j        t          ¦  «         |                      d|d         j        j        ¦  «         |                      d|d         j        j        ¦  «         dS )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Ú321r=   )Úwebr?   r@   ztwisted.web)r)   r.   rA   r   r8   r#   rE   r>   r9   s     r   Útest_packageWithModulez(MakePackagesTests.test_packageWithModule�   sñ   € ð
 ˆÝ�d�D­µ$¸uÐ2EÑ2EÔ2EÐ)FÑ)FÔ)FÐGÑGÔGÈÑQÔQÐQØ×Ò˜g¥tÑ,Ô,Ð,Ø×Ò˜g iÔ0µ*Ñ=Ô=Ð=Ø×Ò˜ G¨IÔ$6Ô$?Ñ@Ô@Ð@Ø×Ò˜g iÔ0Ô4µjÑAÔAÐAØ×Ò˜¨°	Ô(:Ô(>Ô(GÑHÔHÐHØ×Ò˜ ¨	Ô 2Ô 6Ô >Ñ?Ô?Ð?Ð?Ð?r   N)r#   r$   r%   r&   r:   rB   rF   r'   r   r   r5   r5   �   sP   € € € € € ðð ð
;ð ;ð ;ð<ð <ð <ð@ð @ð @ð @ð @r   r5   )
r&   r   Útypesr   Útwisted.trial.unittestr   r   r+   r)   r5   r'   r   r   ú<module>rI      sÅ   ððð ð €
€
€
Ø Ð Ð Ð Ð Ð à +Ð +Ð +Ð +Ð +Ð +ð
)ð )ð )ð )ð )ñ )ô )ð )ðB$ð $ð $ðN$ð $ð $ðN(@ð (@ð (@ð (@ð (@˜ñ (@ô (@ð (@ð (@ð (@r   