
    \d:                         d Z ddlmZ ddlmZ ddlmZ  G d d          Zd Z	 G d d	          Z
 G d
 d          Z G d d          Z G d d          ZdS )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                   $    e Zd ZdZd Zd Zd ZdS )IOPumpzUtility to pump data between clients and servers for protocol testing.

    Perhaps this is a utility worthy of being in protocol.py?
    c                 >    || _         || _        || _        || _        d S )N)clientserverclientIOserverIO)selfr	   r
   r   r   s        6lib/python3.11/site-packages/twisted/test/testutils.py__init__zIOPump.__init__   s"          c                 \    |                                  r	 |                                  dS dS )z,Pump until there is no more input or output.N)pump)r   s    r   flushzIOPump.flush!   s;    iikk 	 iikk 	 	 	 	 	r   c                 &   | j                             d           | j                            d           | j                                         }| j                                        }| j                             d           | j                            d           | j                                          | j                                         |D ]}| j                            |           |D ]}| j                            |           |s|rdS dS )zOMove data back and forth.

        Returns whether any data was moved.
        r      )r   seekr   readtruncater
   dataReceivedr	   )r   cDatasDatabytes       r   r   zIOPump.pump&   s   
 	11""$$""$$11       	+ 	+DK$$T**** 	+ 	+DK$$T**** 	E 	11r   N)__name__
__module____qualname____doc__r   r   r    r   r   r   r      sK         
! ! !  
    r   r   c                 :   t                      }t                      }|                    t          |                     |                     t          |                     t          || ||          }|                                 |                                 |S )z-Take two Protocol instances and connect them.)r   makeConnectionr   r   r   )r
   r	   ciosior   s        r   returnConnectedr&   =   s~    
))C
))C
+c**+++
+c**+++&&#s++DJJLLLJJLLLKr   c                       e Zd ZdZd ZdS )XMLAssertionMixinz
    Test mixin defining a method for comparing serialized XML documents.

    Must be mixed in to a L{test case<unittest.TestCase>}.
    c                     |                      t          j        |                                          t          j        |                                                     dS )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.assertXMLEqualR   sW     	OE""((**COF,C,C,I,I,K,K	
 	
 	
 	
 	
r   N)r   r   r   r    r0   r!   r   r   r(   r(   K   s-         
 
 
 
 
r   r(   c                   "    e Zd ZdZdedefdZdS )_EqualzN
    A class the instances of which are equal to anything and everything.
    otherreturnc                     dS )NTr!   r   r3   s     r   __eq__z_Equal.__eq__f   s    tr   Nr   r   r   r    objectboolr7   r!   r   r   r2   r2   a   s@         F t      r   r2   c                   "    e Zd ZdZdedefdZdS )	_NotEqualz>
    A class the instances of which are equal to nothing.
    r3   r4   c                     dS )NFr!   r6   s     r   r7   z_NotEqual.__eq__o   s    ur   Nr8   r!   r   r   r<   r<   j   s@         F t      r   r<   c                       e Zd ZdZd ZdS )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                 Z   |                      ||k               |                      ||k               |                     ||k               |                     ||k               |                     ||k               |                      ||k               |                      |t                      k               |                     |t                      k               |                     |t                      k               |                      |t                      k               dS )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assertFalser2   r<   )r   firstValueOnesecondValueOnevalueTwos       r   "assertNormalEqualityImplementationz7ComparisonTestsMixin.assertNormalEqualityImplementation   s
   . 	67777888(2333-7888.899912221222&((2333)++5666455555r   N)r   r   r   r    rF   r!   r   r   r?   r?   s   s-          6  6  6  6  6r   r?   N)r    ior   xml.domr   r+   twisted.internet.protocolr   r   r&   r(   r2   r<   r?   r!   r   r   <module>rJ      s)  	 	       " " " " " " 1 1 1 1 1 1% % % % % % % %P  
 
 
 
 
 
 
 
,              .6 .6 .6 .6 .6 .6 .6 .6 .6 .6r   