%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__/testutils.cpython-312.pyc

�

Ϫ�f:���dZddlmZddlmZddlmZGd�d�Zd�Z	Gd�d	�Z
Gd
�d�ZGd�d
�ZGd�d�Z
y)a�
I{Private} test utilities for use throughout Twisted's test suite.  Unlike
C{proto_helpers}, this is no exception to the
don't-use-it-outside-Twisted-we-won't-maintain-compatibility rule!

@note: Maintainers be aware: things in this module should be gradually promoted
    to more full-featured test helpers and exposed as public API as your
    maintenance time permits.  In order to be public API though, they need
    their own test cases.
�)�BytesIO)�minidom)�FileWrapperc�"�eZdZdZd�Zd�Zd�Zy)�IOPumpz�Utility to pump data between clients and servers for protocol testing.

    Perhaps this is a utility worthy of being in protocol.py?
    c�<�||_||_||_||_y)N)�client�server�clientIO�serverIO)�selfr	r
rrs     �8/usr/lib/python3/dist-packages/twisted/test/testutils.py�__init__zIOPump.__init__s�������� ��
� ��
�c�J�|j�r	|j�r�yy)z,Pump until there is no more input or output.N)�pump)r
s r�flushzIOPump.flush!s���i�i�k���i�i�krc�>�|jjd�|jjd�|jj�}|jj�}|jjd�|jjd�|jj	�|jj	�|D]}|j
j
|��|D]}|jj
|��|s|ryy)zOMove data back and forth.

        Returns whether any data was moved.
        r�)r�seekr�read�truncater
�dataReceivedr	)r
�cData�sData�bytes    rrzIOPump.pump&s���
	
�
�
���1���
�
���1���
�
�"�"�$���
�
�"�"�$���
�
���1���
�
���1���
�
��� ��
�
��� ��	+�D��K�K�$�$�T�*�	+��	+�D��K�K�$�$�T�*�	+��E��rN)�__name__�
__module__�__qualname__�__doc__rrr�rrrrs���
!��
rrc���t�}t�}|jt|��|jt|��t||||�}|j	�|j	�|S)z-Take two Protocol instances and connect them.)r�makeConnectionrrr)r
r	�cio�siors     r�returnConnectedr&=s]��
�)�C�
�)�C�
���+�c�*�+�
���+�c�*�+��&�&�#�s�+�D��J�J�L��J�J�L��Krc��eZdZdZd�Zy)�XMLAssertionMixinz�
    Test mixin defining a method for comparing serialized XML documents.

    Must be mixed in to a L{test case<unittest.TestCase>}.
    c��|jtj|�j�tj|�j��y)z�
        Verify that two strings represent the same XML document.

        @param first: An XML string.
        @type first: L{bytes}

        @param second: An XML string that should match C{first}.
        @type second: L{bytes}
        N)�assertEqual�dom�parseString�toxml)r
�first�seconds   r�assertXMLEqualz XMLAssertionMixin.assertXMLEqualRs;��	
����O�O�E�"�(�(�*�C�O�O�F�,C�,I�,I�,K�	
rN)rrrr r0r!rrr(r(Ks���
rr(c� �eZdZdZdedefd�Zy)�_EqualzN
    A class the instances of which are equal to anything and everything.
    �other�returnc��y)NTr!�r
r3s  r�__eq__z
_Equal.__eq__fs��rN�rrrr �object�boolr7r!rrr2r2as����F��t�rr2c� �eZdZdZdedefd�Zy)�	_NotEqualz>
    A class the instances of which are equal to nothing.
    r3r4c��y)NFr!r6s  rr7z_NotEqual.__eq__os��rNr8r!rrr<r<js����F��t�rr<c��eZdZdZd�Zy)�ComparisonTestsMixina�
    A mixin which defines a method for making assertions about the correctness
    of an implementation of C{==} and C{!=}.

    Use this to unit test objects which follow the common convention for C{==}
    and C{!=}:

        - The object compares equal to itself
        - The object cooperates with unrecognized types to allow them to
          implement the comparison
        - The object implements not-equal as the opposite of equal
    c���|j||k(�|j||k(�|j||k(�|j||k7�|j||k7�|j||k7�|j|t�k(�|j|t�k7�|j|t�k(�|j|t�k7�y)aU
        Assert that C{firstValueOne} is equal to C{secondValueOne} but not
        equal to C{valueOne} and that it defines equality cooperatively with
        other types it doesn't know about.

        @param firstValueOne: An object which is expected to compare as equal
            to C{secondValueOne} and not equal to C{valueTwo}.

        @param secondValueOne: A different object than C{firstValueOne} but
            which is expected to compare equal to that object.

        @param valueTwo: An object which is expected to compare as not equal to
            C{firstValueOne}.
        N)�
assertTrue�assertFalser2r<)r
�
firstValueOne�secondValueOne�valueTwos    r�"assertNormalEqualityImplementationz7ComparisonTestsMixin.assertNormalEqualityImplementation�s���.	
���
��6�7����
��7�8�����(�2�3�����-�7�8�����.�8�9����
��1�2����
���1�2�����&�(�2�3�����)�+�5�6����
���4�5rN)rrrr rFr!rrr?r?ss��� 6rr?N)r �ior�xml.domrr+�twisted.internet.protocolrrr&r(r2r<r?r!rr�<module>rJsM��	��"�1�%�%�P�
�
�,����.6�.6r

Zerion Mini Shell 1.0