%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f���^�dZddlZddlmZddlmZGd�d�Zd�Zd�ZGd	�d
e�Z	y)zt
Tests for miscellaneous behaviors of the top-level L{twisted} package (ie, for
the code in C{twisted/__init__.py}.
�N)�
ModuleType)�TestCasec�(�eZdZdZd�Zd�Zd�Zd�Zy)�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��||_y�N)�name)�selfr	s  �;/usr/lib/python3/dist-packages/twisted/test/test_twisted.py�__init__zSetAsideModule.__init__s	����	�c��ttjj��D��cic]5\}}||jk(s|j|jdz�r||��7}}}|D]}tj|=�|Scc}}w)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�modulers     r�	_unimportzSetAsideModule._unimports���)-�S�[�[�->�->�-@�(A�
�$��V��d�i�i�'�:�+@�+@����S��+Q�
���
��
�
�	"�D����D�!�	"����
s�:Bc�D�|j|j�|_yr)rr	r)r
s r�	__enter__zSetAsideModule.__enter__+s���~�~�d�i�i�0��r
c��|j|j�tjj	|j�yr)rr	rr�update)r
�excType�excValue�	tracebacks    r�__exit__zSetAsideModule.__exit__.s(�����t�y�y�!������4�<�<�(r
N)�__name__�
__module__�__qualname__�__doc__rrrr�r
rrrs�����1�)r
rc�`�i}td||�tjj|�y)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)�
_makePackagesrrr)r�results  r�_installr(3s(��D�F��$���(��K�K���v�r
c���i}t|j��D]�\}}|�Mt|t�r7t	|�}|j
j
t|||��|||<�O|||<�Ut|t�r\t	|jdz|z�}|j
j
t|||��|||jdz|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}.
    r)	rr�
isinstance�dictr�__dict__rr&r )�parent�
attributesr'�attrsr	�valuers       rr&r&Zs���&
�E��J�,�,�.�/�$���e��>��%��&�#�D�)�����&�&�}�V�U�F�'K�L�%��t��$��t���%��&�#�F�O�O�c�$9�D�$@�A�����&�&�}�V�U�F�'K�L�7=��v����,�t�3�4�$��d��#��d��$� �Lr
c�"�eZdZdZd�Zd�Zd�Zy)�MakePackagesTestszh
    Tests for L{_makePackages}, a helper for populating C{sys.modules} with
    fictional modules.
    c�n�i}tdtd��|�|j|td���y)z�
        A non-C{dict} value in the attributes dictionary passed to L{_makePackages}
        is preserved unchanged in the return value.
        N�reactor)r4)r&r+�assertEqual�r
rs  r�test_nonModulez MakePackagesTests.test_nonModule�s/��
���d�D��3�W�=�����$�y�"9�:r
c�$�i}tdttd����|�|j|t�|j|dt�|j	d|dj
�|j	d|dj�y)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+�assertIsInstancerr5r r;r6s  r�test_moduleWithAttributez*MakePackagesTests.test_moduleWithAttribute�sz�����d�D��e�)<�=�w�G����g�t�,����g�i�0�*�=�����G�I�$6�$?�$?�@������	� 2� :� :�;r
c
���i}tdtttd������|�|j|t�|j|dt�|j	d|dj
�|j|djt�|j	d|djj
�|j	d|djj�y)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=ztwisted.web)r&r+r>rr5r rBr;r6s  r�test_packageWithModulez(MakePackagesTests.test_packageWithModule�s���
���d�D��$�u�2E�)F�G��Q����g�t�,����g�i�0�*�=�����G�I�$6�$?�$?�@����g�i�0�4�4�j�A������	�(:�(>�(>�(G�(G�H������	� 2� 6� 6� >� >�?r
N)r r!r"r#r7r?rCr$r
rr2r2�s���
;�<�@r
r2)
r#r�typesr�twisted.trial.unittestrrr(r&r2r$r
r�<module>rFs:�����+�
)�)�B$�N$�N(@��(@r

Zerion Mini Shell 1.0