HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/test/__pycache__/testutils.cpython-38.pyc
U


W[��@s�dZddlmZddlmZddlmZGdd�d�Zdd�Z	Gd	d
�d
e
�ZGdd�de
�ZGd
d�de
�Z
Gdd�de
�ZdS)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@s(eZdZdZdd�Zdd�Zdd�ZdS)	�IOPumpz�Utility to pump data between clients and servers for protocol testing.

    Perhaps this is a utility worthy of being in protocol.py?
    cCs||_||_||_||_dS)N)�client�server�clientIO�serverIO)�selfrrrr	�r�8/usr/lib/python3/dist-packages/twisted/test/testutils.py�__init__szIOPump.__init__cCs|��r
qdS)z,Pump until there is no more input or output.N)�pump)r
rrr�flush"szIOPump.flushcCs�|j�d�|j�d�|j��}|j��}|j�d�|j�d�|j��|j��|D]}|j�|�q\|D]}|j�|�qr|s�|r�dSdSdS)zOMove data back and forth.

        Returns whether any data was moved.
        r�N)r�seekr	�read�truncaterZdataReceivedr)r
ZcDataZsDataZbyterrrr's



zIOPump.pumpN)�__name__�
__module__�__qualname__�__doc__r
rrrrrrrsrcCsJt�}t�}|�t|��|�t|��t||||�}|��|��|S)z2Take two Protocol instances and connect them.
    )rZmakeConnectionrrr)rrZcioZsiorrrr�returnConnected?src@seZdZdZdd�ZdS)�XMLAssertionMixinz�
    Test mixin defining a method for comparing serialized XML documents.

    Must be mixed in to a L{test case<unittest.TestCase>}.
    cCs$|�t�|���t�|����dS)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)ZassertEqual�domZparseStringZtoxml)r
�first�secondrrr�assertXMLEqualVs
�z XMLAssertionMixin.assertXMLEqualN)rrrrrrrrrrOsrc@s eZdZdZdd�Zdd�ZdS)�_EqualzN
    A class the instances of which are equal to anything and everything.
    cCsdS�NTr�r
�otherrrr�__eq__jsz
_Equal.__eq__cCsdS�NFrr rrr�__ne__nsz
_Equal.__ne__N�rrrrr"r$rrrrrfsrc@s eZdZdZdd�Zdd�ZdS)�	_NotEqualz>
    A class the instances of which are equal to nothing.
    cCsdSr#rr rrrr"wsz_NotEqual.__eq__cCsdSrrr rrrr${sz_NotEqual.__ne__Nr%rrrrr&ssr&c@seZdZdZdd�ZdS)�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
    cCs�|�||k�|�||k�|�||k�|�||k�|�||k�|�||k�|�|t�k�|�|t�k�|�|t�k�|�|t�k�dS)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)Z
assertTrueZassertFalserr&)r
Z
firstValueOneZsecondValueOneZvalueTworrr�"assertNormalEqualityImplementation�sz7ComparisonTestsMixin.assertNormalEqualityImplementationN)rrrrr(rrrrr'�sr'N)r�iorZxml.domrrZtwisted.internet.protocolrrr�objectrrr&r'rrrr�<module>s(